View previous topic :: View next topic |
Author |
Message |
shekar123 Advanced
Joined: 22 Jul 2005 Posts: 528 Topics: 90 Location: Bangalore India
|
Posted: Thu Sep 29, 2005 5:29 am Post subject: displaying Signed values |
|
|
Code: |
05 A PIC S9(08).
05 B PIC 9(08).
MOVE 34 TO A B.
DISPLAY 'A IS ' A.
DISPLAY 'B IS ' B.
OUTPUT:
A IS 0000003D
B IS 00000034
|
Hai,
I am basically trying to display signed numbers and i have the followig code and the output.My understanding is that variable B is displayed properly,but i the value of variable A is 3D.Now if in this case i want to know the exact value of variable A ,how do i do that ?I try to put HEX ON and i get the following display and i refer the table EBCDIC - ASCII table and conclude that the hex value C4 is displayed ,but has the deciaml value 196 associated with it.Can anyone let me know how do i calculate / how do i know the exact value of the variable A whether it is positive / negative ? My understanding is that in case of signed numbers the sign is punched over the last byte.Pleae guide me how do i know the value of variable A as i am clearly seeing the value of variable B as 34 in the display.If i need to move the value of the variable to a edited variable how do i that ?
[code:1:19bc608adf]
A
--
0000003D
FFFFFFFC
00000034
B
--
00000034
FFFFFFFF
00000034
EBCDIC - ASCII table
Hx Dec E A Hx Dec E A Hx Dec E A Hz Dec E A
00 00 NUL 20 32 SP 40 64 SP @ 60 96 - '
01 01 21 33 ! 41 65 A 61 97 / a
02 02 22 34 |
|
Back to top |
|
 |
Phantom Data Mgmt Moderator

Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
|
Posted: Thu Sep 29, 2005 5:45 am Post subject: |
|
|
Shekar123,
If this is just for a display purpose use numeric edited fields. 'Z' is a Zero Suppression variable and '-' refers to Sign bit. In case of positive value blanks will be prefixed and when negative the '-' will appear before the number.
Try this code.
Code: |
05 A PIC S9(08).
05 B PIC 9(08).
05 C PIC -Z(08).
05 D PIC Z(08).
MOVE 34 TO A B.
DISPLAY 'A IS ' A.
DISPLAY 'B IS ' B.
MOVE A TO C
MOVE B TO D
DISPLAY 'Edited Value of A is: ' C.
DISPLAY 'Edited Value of B is: ' D.
|
Also, in future please use the BB Tags when you paste any code. Enclose your piece of code b/w {code} and {/code} (You need to change '{' by '[' & '}' by ']'). This makes your code more legible to read and understand. Also, you won't get the emoticons when you use 8 & ).
Thanks,
Phantom |
|
Back to top |
|
 |
shekar123 Advanced
Joined: 22 Jul 2005 Posts: 528 Topics: 90 Location: Bangalore India
|
Posted: Thu Sep 29, 2005 10:22 am Post subject: displaying Signed values |
|
|
Thanks Phantom,
I have understood the concept and i have tried out displaying with your code,and it worked fine.I still have some doubt in my mind.If i see a report which has say 3D in one of the variable,how do i interpret the value of 3D as to what it is ? Should i see the table which i have pasted / should i use any other method to confirm that 3D means 34 value decimal.
Please guide me how to go about it. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12380 Topics: 75 Location: San Jose
|
Posted: Thu Sep 29, 2005 10:31 am Post subject: |
|
|
Quote: |
If i see a report which has say 3D in one of the variable,how do i interpret the value of 3D as to what it is ? Should i see the table which i have pasted / should i use any other method to confirm that 3D means 34 value decimal.
Please guide me how to go about it.
|
Shekhar123,
keep this chart handy. For zoned decimal numbers , the following is the notation.
Code: |
**********************************************************************
* 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 = } *
**********************************************************************
|
Hope this helps..
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
prakal Beginner
Joined: 14 Mar 2003 Posts: 22 Topics: 1
|
Posted: Thu Sep 29, 2005 10:33 am Post subject: |
|
|
shekar123
Here is a sample cheat sheet that can be used to interpret zoned decimals
Code: |
+---------------------------------------------------------------+
| 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 |
+---------------------------------------------------------------+
|
Prakal |
|
Back to top |
|
 |
shekar123 Advanced
Joined: 22 Jul 2005 Posts: 528 Topics: 90 Location: Bangalore India
|
Posted: Thu Sep 29, 2005 11:34 am Post subject: displaying Signed values |
|
|
Thanks Kolusu & Prakal,
You guys are great.I have clearly understood the basics of representing zoned decimals. |
|
Back to top |
|
 |
|
|