× 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.




Packed fields (sometimes called "binary coded decimal") are stored by keeping one decimal digit in each nibble of a byte.

Consider the decimal number 123. To make that packed, you convert each digit to binary, so that you have:

1 = 0001
2 = 0010
3 = 0011

Then, you need to keep track of whether your number is positive or negative. To do that, they decided to use

positive = 1111
negative = 1101

So, to store the number 123 (as a positive number) as a packed decimal, you'd have 4 nibbles that look like this:

   0001 0010 0011 1111

Combine the nibbles to make bytes, and you have

   00010010 00111111

In hex, that would look like this:

   x'123F'

That's actually kinda nice, because it makes it easy for us to debug our numbers. We just display them in hex and we can read the value of the number from them very easily.

Since data on a computer is stored in bytes, and since one nibble (half of a byte) is always required for a sign, the number of digits in a packed field is always: (bytes x 2) - 1

I get a syntax error in SEU That the Decimal Portion is greater than the Field Length

In your case, you have the following definition

     I            DS
     I                                    P   1   36MYFLD

Since this is a field that goes from byte 1 to byte 3 of a data structure, we know that it's 3 bytes long. So how many digits is it? 3 x 2 = 6,
6 - 1  = 5.  It's 5 digits long.

In order to have 6 decimal places you need at least 6 digits. You can't tell the computer to make 6 decimal places unless there are at least 6 digits to take them from :)

But in RPG III is it  P 1    6 6
Or would this be considered a 9 position with 6 decimal

It's taking up 6 bytes. Think about that... 6 bytes is 12 nibbles. Since one of those nibbles is used for the sign (positive or negative) there are 11 digits left.

So, this is an 11 digit number, and 6 of those digits are used as decimal places.

In other words, it would store a number like 99999.999999. The equivalent in DDS or ILE RPG would be "11P 6".

In the future please do us a favor and don't quote back the entire digest.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.