View previous topic :: View next topic |
Author |
Message |
ANDY Beginner
Joined: 07 Feb 2004 Posts: 127 Topics: 67
|
Posted: Tue Aug 01, 2006 10:50 pm Post subject: How to display sign value correctly? |
|
|
Code: | 77 A PIC S99V9 VALUE -21.3.
77 B PIC S99V9 VALUE 4.5.
DISPLAY 'A = ' A.
DISPLAY 'B = ' B. |
The following result is incorrect. How to show correctly ?
_________________ cheers,
Andy |
|
Back to top |
|
|
shekar123 Advanced
Joined: 22 Jul 2005 Posts: 528 Topics: 90 Location: Bangalore India
|
Posted: Wed Aug 02, 2006 12:31 am Post subject: |
|
|
Andy,
The result is not incorrect.Please use this cheat sheet to interpret zoned numbers.
Code: |
A = 21L
B = 04E
**********************************************************************
* VALUES: *
* 1 = A -1 = J EXAMPLES: NUMBER REPRESENTATION *
* 2 = B -2 = K 10 00000001{ *
* 3 = C -3 = L 105 00000010E *
* 4 = D -4 = M 0 00000000{ *
* 5 = E -5 = N -234 00000023M *
* 6 = F -6 = O -30 00000003} *
* 7 = G -7 = P *
* 8 = H -8 = Q *
* 9 = I -9 = R *
* 0 = { -0 = } *
**********************************************************************
21L would be -21.3
04E would be 4.5
+---------------------------------------------------------------+
| Last Character will be | |
| represented as below for.. | 0 1 2 3 4 5 6 7 8 9 |
+---------------------------------------------------------------+
| If the Number is +ve | { A B C D E F G H I |
+---------------------------------------------------------------+
| If the Number is -ve | } J K L M N O P Q R |
+---------------------------------------------------------------+
|
However if you want to display in readable format try this code:
Code: |
WORKING-STORAGE SECTION.
77 A PIC S99V9 VALUE -21.3.
77 B PIC S99V9 VALUE 4.5.
77 A-EDITED PIC -ZZ.Z.
77 B-EDITED PIC -ZZ.Z.
PROCEDURE DIVISION.
DISPLAY 'A = ' A.
DISPLAY 'B = ' B.
MOVE A TO A-EDITED.
MOVE B TO B-EDITED.
DISPLAY 'A-EDITED ' A-EDITED.
DISPLAY 'B-EDITED ' B-EDITED.
STOP RUN.
|
OUTPUT
Code: |
A = 21L
B = 04E
A-EDITED -21.3
B-EDITED 4.5
|
_________________ Shekar
Grow Technically |
|
Back to top |
|
|
semigeezer Supermod
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
|
Posted: Wed Aug 02, 2006 10:02 am Post subject: |
|
|
Now THAT is a USEFUL post (especially to those of us who do a COBOL program once every 2 years!) Thanks |
|
Back to top |
|
|
ANDY Beginner
Joined: 07 Feb 2004 Posts: 127 Topics: 67
|
Posted: Mon Aug 07, 2006 4:19 am Post subject: |
|
|
Thank you very much. _________________ cheers,
Andy |
|
Back to top |
|
|
nagasadhu Beginner
Joined: 08 Jul 2006 Posts: 17 Topics: 6
|
Posted: Fri Jan 26, 2007 11:25 am Post subject: |
|
|
Hi
Can someone please post the similar cheat sheet for packed decimal values as well?
A link to the appropriate manual is highly appreciated.
Thanks |
|
Back to top |
|
|
programmer1 Beginner
Joined: 18 Feb 2004 Posts: 138 Topics: 14
|
Posted: Tue Jan 30, 2007 2:12 pm Post subject: |
|
|
nagasadhu,
You will not be able to use a HEX to ASCII conversion sheet like the one above because you cannot interpret the packed decimal characters unless they are in HEX/Binary format. _________________ Regards,
Programmer |
|
Back to top |
|
|
vak255 Intermediate
Joined: 10 Sep 2004 Posts: 384 Topics: 79
|
Posted: Thu Feb 01, 2007 2:10 pm Post subject: |
|
|
Good sheat sheet.Still you can view it by making it hex on and then try to figure out whats the actual issue. |
|
Back to top |
|
|
|
|