View previous topic :: View next topic
|
Author |
Message |
simimathew
New User
Joined: 26 Jan 2006 Posts: 23 Location: London
|
|
|
|
Can somebody please tell me the difference between the following data declarations?
1. 03 ZB-COMMA-SI-LIMITS PIC -(3)9.99.
2. 03 ZB-COMMA-SI-LIMITS PIC Z(3)9.99.
What will happen if a decimal number, 0017.45, is moved to the field ZB-COMMA-SI-LIMITS in both cases? As per my understanding both will suppress the preceeding zeros (if the declaration had been 9(4).99, there would have been preceeding zeros) and replace them with spaces.
Please let me know the difference, if any.
Also is a declaration
03 ZB-COMMA-SI-LIMITS PIC Z,ZZZ,ZZZ,ZZZ,ZZ9.99.
valid????
Many Thanks,
Simi |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Quote: |
1. 03 ZB-COMMA-SI-LIMITS PIC -(3)9.99.
2. 03 ZB-COMMA-SI-LIMITS PIC Z(3)9.99.
What will happen if a decimal number, 0017.45, is moved to the field ZB-COMMA-SI-LIMITS in both cases? As per my understanding both will suppress the preceeding zeros (if the declaration had been 9(4).99, there would have been preceeding zeros) and replace them with spaces.
Please let me know the difference, if any.
|
The output from both these are identical.
Quote: |
03 ZB-COMMA-SI-LIMITS PIC Z,ZZZ,ZZZ,ZZZ,ZZ9.99.
valid???? |
Yes, this is valid.
Dave |
|
Back to top |
|
|
simimathew
New User
Joined: 26 Jan 2006 Posts: 23 Location: London
|
|
|
|
Thanks, Dave.
But I have one more clarification to make regarding the formatting.
If a field is declared as
03 DL6140-DAYS-OS PIC -(5)9.
What will be the output when u move a negative number -12345 to thsi field? Actually my question is, are we using this PIC clause to show the -ve sign as well. So in that case will PIC-(5)9 and PIC Z(5)9 be the same?
Please help me out.
Thanks in advance,
Simi |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Simi,
In this case you will get different results.
The PIC -(5)9 will result in "-12345"
and the PIC Z(5)9 will result in " 12345"
Both of these reserve 6 bytes, the -(5)9 is signed and will place a "-" as the leading byte if the value is negative. The Z(5)9 is unsigned and no sign, +/- will appear.
If you were to move a -123456 to both of these fields, the Z(5)9 will result in "123456" where the -(5)9 will truncate the Most Significant Byte and result in "-23456"
Dave |
|
Back to top |
|
|
simimathew
New User
Joined: 26 Jan 2006 Posts: 23 Location: London
|
|
|
|
Thanks Dave. |
|
Back to top |
|
|
|