Hi,
One of the filed is defined as PIC 9(4) in the program. If input file has got negative values for this variable, what the program will receive? Will program just take the value and ignores the sign OR interpretes into some other value?
I was not able to answer the question well. I think move will be fine but it'll move in the absolute value of the sending field. Can there be some erroror warning by compiler? Or is there a way we can receive the value with sign?
Moving negative values into unsigned data variable.
-
- Registered Member
- Posts: 31
- Joined: Thu Oct 03, 2013 1:32 pm
-
- Global Moderator
- Posts: 490
- Joined: Sun Aug 25, 2013 7:24 pm
Re: Moving negative values into unsigned data variable.
If you MOVE a signed value to an unsigned numeric field, you will simply get the absolute value as you suspect. The is no compiler diagnostic for this.
You could get an actual sign into an unsigned field using REDEFINES. This would be a bad idea. If using NUMPROC(PFD) you could get unexpected results (using PFD, all your data should conform to PICture). Using NOPFD your program would produce expected results, although it would take longer to do so. You'd also risk a mixture of equivalent values (signed and unsigned) being SORTed upon, with unexpected results. So, it can be done, manually, and it is a bad idea.
You could get an actual sign into an unsigned field using REDEFINES. This would be a bad idea. If using NUMPROC(PFD) you could get unexpected results (using PFD, all your data should conform to PICture). Using NOPFD your program would produce expected results, although it would take longer to do so. You'd also risk a mixture of equivalent values (signed and unsigned) being SORTed upon, with unexpected results. So, it can be done, manually, and it is a bad idea.
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute