I spent couple of days trying to understand it. After any arithmetics with packed or zoned decimal the result value is always positive.
when I do
VAR1 W 4 P
VAR1 = 4 - 5
DISPLAY HEX VAR1
I see the value : X'0000001F' and not X'0000001D'
The same when I do VAR1 = -1 * VAR1 and so on.
I tried different variants, getting values from a file, putting into a file, packed variables and zoned decimal.
Internally calculations are correct. If I do : VAR1 = 4 -5 + 2 , the result is +1
but if I do
RES1 = 4 - 5
RES1 = RES1 + 2
The result is +3
Any clue?
Thanks!
I can't assign any negative value to any variable
- dick scherrer
- Global moderator
- Posts: 6268
- Joined: Sat Jun 09, 2007 8:58 am
Re: I can't assign any negative value to any variable
Hello Yurad and welcome to the forums,
Instead of thisand reply back with what happens.
Instead of this
please tryVAR1 W 4 P
Code: Select all
VAR1 W 4 P 0
Hope this helps,
d.sch.
d.sch.
-
- Posts: 18
- Joined: Thu Jan 31, 2008 7:14 am
- Skillset: cobol, jcl, pl/1, db2, clist, cics
- Referer: internet search
Re: I can't assign any negative value to any variable
thank you, Dick!
It's fine! Just unusual logic for me to swith between unsigned/signed arithmetic.
Thank you again!
It's fine! Just unusual logic for me to swith between unsigned/signed arithmetic.
Thank you again!
- dick scherrer
- Global moderator
- Posts: 6268
- Joined: Sat Jun 09, 2007 8:58 am
Re: I can't assign any negative value to any variable
You're welcome - good to hear it is working
d

d