I can't assign any negative value to any variable



Unicenter CA-Easytrieve Plus Report Generator: CA's information retrieval and data management tool

I can't assign any negative value to any variable

Postby yurad » Thu Jan 31, 2008 9:16 am

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!
yurad
 
Posts: 18
Joined: Thu Jan 31, 2008 7:14 am
Has thanked: 0 time
Been thanked: 0 time

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

Postby dick scherrer » Fri Feb 01, 2008 12:21 am

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.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

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

Postby yurad » Fri Feb 01, 2008 9:11 pm

thank you, Dick!
It's fine! Just unusual logic for me to swith between unsigned/signed arithmetic.
Thank you again!
yurad
 
Posts: 18
Joined: Thu Jan 31, 2008 7:14 am
Has thanked: 0 time
Been thanked: 0 time

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

Postby dick scherrer » Fri Feb 01, 2008 11:06 pm

You're welcome - good to hear it is working :)

d
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to CA-Easytrieve

 


  • Related topics
    Replies
    Views
    Last post