Page 1 of 1

I can't assign any negative value to any variable

PostPosted: Thu Jan 31, 2008 9:16 am
by yurad
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!

Re: I can't assign any negative value to any variable

PostPosted: Fri Feb 01, 2008 12:21 am
by dick scherrer
Hello Yurad and welcome to the forums,

Instead of this
VAR1 W 4 P
please try
VAR1 W 4 P 0
and reply back with what happens.

Re: I can't assign any negative value to any variable

PostPosted: Fri Feb 01, 2008 9:11 pm
by yurad
thank you, Dick!
It's fine! Just unusual logic for me to swith between unsigned/signed arithmetic.
Thank you again!

Re: I can't assign any negative value to any variable

PostPosted: Fri Feb 01, 2008 11:06 pm
by dick scherrer
You're welcome - good to hear it is working :)

d