Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CONVERTION DECIMAL IN PACKED NUMBERS

3 views
Skip to first unread message

Andrea Monaci

unread,
Jan 29, 1999, 3:00:00 AM1/29/99
to
HI

How does you become to convert by hand a decimal number in a Packed decimal
or BCD (Binary Coded Decimal) number?

THANKS

BYE

Andrea Monaci

My address is:

Via A.Gramsci N. 96
C.A.P.: 35010 Cadoneghe (Padova) (Italy)
Tel/Fax: 0039-049700637
E-Mail: amo...@protec.it

Warren Porter

unread,
Jan 29, 1999, 3:00:00 AM1/29/99
to
Andrea Monaci wrote:

> How does you become to convert by hand a decimal number in a Packed decimal
> or BCD (Binary Coded Decimal) number?

I assume you will be doing this in something other than COBOL. Each byte
(except possibly the last) contains two digits while the low order byte last 4
bit positions may contain a sign. In general, to get the first digit, divide
the byte by 16 or shift to the right by 4 bits. To get the low order digit, AND
the byte by 15 (x'0F') or mod the byte by 16. HTH.

If the field is signed, the sign will be in the rightmost 4 bits. On some
machines 15 is unsigned (or positive), 12 is positive, and 13 is negative, but,
"Your milage may vary".

--
Warren Porter

stcheong

unread,
Jan 30, 1999, 3:00:00 AM1/30/99
to
How about dropping the first 4 bytes of both numeric values and joining them
back together.
Hope it works.

Andrea Monaci wrote in message <36b18fda...@news.interbusiness.it>...
>HI


>
>How does you become to convert by hand a decimal number in a Packed
decimal
>or BCD (Binary Coded Decimal) number?
>

0 new messages