View previous topic :: View next topic |
Author |
Message |
tvssv Beginner
Joined: 11 Mar 2009 Posts: 58 Topics: 25
|
Posted: Tue Apr 14, 2020 7:00 am Post subject: PL/I Help on PIC variable. |
|
|
Hi,
I am declaring a variable as PIC '-------9'. I am getting value into this variable negative value for now. In future there is chance to getting positive value also to this variable. Actually we can declare as PIC 'SSSSS9' to receive any value either positive or negative. But the same program in production is using
PIC '-----9' and that program is running fine even if it is getting positive values. But as per PL/I manual it says
+ Position(s) of (drifting) plus sign if number >= 0
- Position(s) of (drifting) minus sign if number < 0
S Position(s) of (drifting) plus sign or minus sign
I am not getting the point how PIC '------9' is working for positive values also. Could someone please give clarification on this.
Thanks. _________________ Thanks
TVSSV |
|
Back to top |
|
|
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Tue Apr 14, 2020 8:23 am Post subject: |
|
|
You can clarify easily enough by yourself. Write a little program to declare a variable with a floating - and move a positive number into it and display it. Repeat with a negative number. _________________ Utility and Program control cards are NOT, repeat NOT, JCL. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
|
Back to top |
|
|
tvssv Beginner
Joined: 11 Mar 2009 Posts: 58 Topics: 25
|
Posted: Tue Apr 14, 2020 1:03 pm Post subject: Read negarive value from file to variable in program. |
|
|
Hi,
I need to read the value from file which is negative value for now but positive values also come . Now the value is -4912315.
I have declared in program is below.
DCL 1 BBK_DETAIL BASED (BBKDET_PTR),
3 NET_BOOKING FIXED FIXED BIN(31);
But I am not getting correct value into the field.I am getting 1626667505 instead of -4912315. Please help me out how to declare. I tried declaring it as pic 'ssssssss9'. It is working but this field is involved in arithmetic operations.
Please help. _________________ Thanks
TVSSV |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Tue Apr 14, 2020 8:48 pm Post subject: |
|
|
tvssv,
what is stopping you from doing this simple thing?
Code: |
DCL INPT CHAR(08) INIT('-4912315') ;
DCL MYNUM FIXED BIN(31) ;
MYNUM = INPT ;
PUT SKIP LIST('MYNUM =',MYNUM) ;
INPT = '+15'
MYNUM = INPT ;
PUT SKIP LIST('MYNUM =',MYNUM) ;
|
PS: Make sure you handle conversion Errors _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
tvssv Beginner
Joined: 11 Mar 2009 Posts: 58 Topics: 25
|
Posted: Fri Apr 17, 2020 11:36 am Post subject: |
|
|
Thank You Kolusu.
DCL INPT CHAR(08) INIT('-4912315') ; with this declaration it is working fine.
I have delcared it as PIC 'SSSSSSS9' it was working fine but if value is '28653680' it is not working because I was getting value 2865368 instead of 28653680. So program was abending. With CHAR(08) DECLARE it is working fine now.
Thank You.
[/code] _________________ Thanks
TVSSV |
|
Back to top |
|
|
|
|