× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Bruce,

When you have a field of length say eleven and want to define in terms of
packed decimal then we need to calculate with  formula i.e. N+1 / 2 = 6
length 

When you look at a field of 6p then want to determine what length of value
would it accommodate then it would be N X 2 - 1 = 11 length 

Thanks
Sadiq 

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Bruce Guetzkow
Sent: Friday, August 26, 2005 5:10 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: RE: Data structure gets populated for a junk value

Sadiq:

<snip>
I understand the meaning of packed decimal when compared to zoned as 
Packed decimal means N X 2 - 1 where "N" stands for length as an example
6p(2)  will accommodate 6 X 2 - 1 = 11 length out of which two are
decimal
values , where as 6S(2) zoned has only a value of six length out of
which
two are decimal
</snip>

Actually, you don't understand the meaning of packed.  An 11,2 field,
whether packed or zoned, contains a maximum value of 999,999,999.99.
The difference is in how it is stored in the database.  A zoned field
takes up the full 11 bytes of storage.  A packed field size is
calculated as (N+1)/2, in this case a length of 6 bytes.  But the field
is still 11,2 and still contains a maximum value of 999,999,999.99.  In
DDS the definitions would be

     A            ZONED         11S 2
     A            PACKED        11P 2

In hex, the fields look like this:

        Zoned           FFFFFFFFFFF
                        99999999999

        Packed  999999
                        99999F

The "F" in the digit portion of the last byte is the sign of the field
(C or F is positive, D is negative).

Whether you use RPG, COBOL, DFU, SQL or any other tool, that packed
field still is only 11,2.

Hope that helps,
--Bruce Guetzkow


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.