View previous topic :: View next topic
|
Author |
Message |
shamus
New User
Joined: 22 Jul 2005 Posts: 7
|
|
|
|
Hi,
I read a file with 2 values, both numeric length 6, both will always be positive, but are not signed.
I want to subtract the second value from the first and display the result, if the result is negative, I need to show the Neg Sign.
I am having trouble showing the sign on the result, any suggestions?
I tried a mask, with no success. I am thinking I need to sign the values I read but dont know how this is done
Any help much appreciated |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Without studying the code, here is one way:
Define a signed field and compute this field as the subtraction of the 2 values. Then move this signed value to your output field definition. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
IIRC, if you define your fields with decimal places e.g. "6 N 0"
Easytrev considers such fields as signed. |
|
Back to top |
|
|
quanzhong
New User
Joined: 12 Aug 2008 Posts: 46 Location: china
|
|
|
|
hi, if you want to define a signed variable, try this
ws-avariable-1 w 6 n 0 // signed
ws-avariable-2 w 6 n // unsigned
Code: |
If you specify a numeric field with decimal positions (0 to 18),
CA-Easytrieve/Plus considers it a signed (quantitative) field.
|
|
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
quanzhong,
thats what i said. Thanks for emphasizing my post. |
|
Back to top |
|
|
|