gnucobol-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[open-cobol-list] Re: How to extract variable value


From: henry wang
Subject: [open-cobol-list] Re: How to extract variable value
Date: Mon Dec 19 04:29:04 2005

Hi Roger,
I got the solution for: 
01  COB_VAR1   COMP-1.
using:
float *p1;
p1=  (b_10);
 
Have a nice day!,
Henry

Roger While <address@hidden> wrote:
Hi Henry,

No, no.

01 COB_VAR1 PIC S9(0006)V PACKED-DECIMAL.

First, look at this defintion. This defines a field in
BCD format. (PACKED-DECIMAL).
There is NO equivalent C definition.
Each defined digit is held in 4 bits (called a "nibble")
with the last (right-most) 4 bits being the sign.

So, we have 6 digits (S9(006) times 4 bits
plus 4 bits at the right for the sign.
This is 3 and one-half bytes which is padded at
the left (with 4 bits) to get 4 bytes total.

The sign is 0X0C for positive and 0X0D for negative.
Unsigned fields get a sign nibble of 0X0F.

So for the above defintion and a content of +123456
Byte 1:
Bits 1 - 4 - 0000 - Padding
Bits 5 - 8 - 0001
Byte 2:
Bits 1 - 4 - 0010
Bits 5 - 8 - 0011
Byte 3:
Bits 1 - 4 - 0100
Bits 5 - 8 - 0101
Byte 4:
Bits 1 - 4 - 0110
Bits 5 - 8 - 1100 - Sign

Hope that clears things up.

Roger



__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


reply via email to

[Prev in Thread] Current Thread [Next in Thread]