View previous topic :: View next topic
|
Author |
Message |
himanshupant
New User
Joined: 21 Mar 2007 Posts: 46 Location: India
|
|
|
|
I am having the same problem in my code as in moving a packed decimal to numeric in easytrieve
My code fragment is as below
BALANCE W 14 N 2
CLEDAB W 8 P 2
When I am doing
BALANCE = CLEDAB
my positive numbers are coming fine but negative numbers are throwing up garbage value in last byte.
For example CLEDAB = 48.23
balance is correctly coming out as 4823
but when cledab = - 3.79
balance is incorrectly coming out as 37R.
So x'379D' is getting converted to x'37D9'. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
And how do you know that ?
By using DISPLAY on the field? |
|
Back to top |
|
|
himanshupant
New User
Joined: 21 Mar 2007 Posts: 46 Location: India
|
|
|
|
PeterHolland wrote: |
And how do you know that ?
By using DISPLAY on the field? |
I am writing the data to a file and seeing the data there !! |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
BALANCE is a zoned decimal field, so it should contain
X'F3F7D9', where D is the negative sign. |
|
Back to top |
|
|
himanshupant
New User
Joined: 21 Mar 2007 Posts: 46 Location: India
|
|
|
|
PeterHolland wrote: |
BALANCE is a zoned decimal field, so it should contain
X'F3F7D9', where D is the negative sign. |
So how can I get the data as 379 with negative sign in this case ? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
himanshupant wrote: |
PeterHolland wrote: |
BALANCE is a zoned decimal field, so it should contain
X'F3F7D9', where D is the negative sign. |
So how can I get the data as 379 with negative sign in this case ? |
Peter,
I can barely hold my water waiting for your response. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
himanshupant
maybe its time to look for another job far far from IT.
That ok, Dick? |
|
Back to top |
|
|
himanshupant
New User
Joined: 21 Mar 2007 Posts: 46 Location: India
|
|
|
|
PeterHolland wrote: |
himanshupant
maybe its time to look for another job far far from IT.
That ok, Dick? |
Friday evening -- seriously I need to move out of IT now |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Either you have a zoned decimal number with a sign
Code: |
X'F3F7D9', where D is the negative sign. |
or a zoned decimal number without a sign
Code: |
X'F3F7F9', where F is the implied positive sign. |
Quote: |
So how can I get the data as 379 with negative sign in this case ? |
How would you have this appear? |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
himanshupant wrote: |
my positive numbers are coming fine but negative numbers are throwing up garbage value in last byte.
For example CLEDAB = 48.23
balance is correctly coming out as 4823
but when cledab = - 3.79
balance is incorrectly coming out as 37R. |
About edit masks the CA-Easytrieve/Plus Reference Guide wrote: |
In some instances, leading zeros add unnecessary information and can confuse
the reader. In these cases, use an edit mask that suppresses leading zeros.
-----9.99 +00001234 12.34
-----9.99 -00001234 -12.34 |
CLEDAB W 8 P 2 MASK '-----9.99'
DISPLAY CLEDAB
48.23 or -3.79 |
|
Back to top |
|
|
himanshupant
New User
Joined: 21 Mar 2007 Posts: 46 Location: India
|
|
|
|
dick scherrer wrote: |
Hello,
Either you have a zoned decimal number with a sign
Code: |
X'F3F7D9', where D is the negative sign. |
or a zoned decimal number without a sign
Code: |
X'F3F7F9', where F is the implied positive sign. |
Quote: |
So how can I get the data as 379 with negative sign in this case ? |
How would you have this appear? |
Hello Dick
Yes so for x'F3F7D9' , it should get written as -3.79
and x'F3F7F9' should get written as 3.79 |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Then you need to specify an "edit mask" as CICS Guy suggested. . . |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
dick scherrer wrote: |
Hello,
Then you need to specify an "edit mask" as CICS Guy suggested. . . |
Edit masks are ok, if you know how to use them.
This TS knows nothing about EZT or numeric values/representations.
And how about this BS :
Quote: |
I am writing the data to a file and seeing the data there !!
|
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hi Peter,
Don't know how you've done things, but i've written "stuff" to a file so i could easily see it in hex. . .
If it is only a bit of data, i usually call a little subroutine (that i've dragged around for 40 years) to show the data in hex but if there is some experimenting to be done, having selected data in a file is quite handy. . .
Quote: |
Edit masks are ok, if you know how to use them. |
Regardless of coding language these need to be understood. . . I rank these somewhat higher than "ok" as pretty much every quantity or amount needs to be "masked" when output to other than a file (screen, report, etc).
Quote: |
This TS knows nothing about EZT or numeric values/representations. |
Maybe not yet - but this will change. . . |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Quote: |
Don't know how you've done things, but i've written "stuff" to a file so i could easily see it in hex. . .
If it is only a bit of data, i usually call a little subroutine (that i've dragged around for 40 years) to show the data in hex but if there is some experimenting to be done, having selected data in a file is quite handy. . .
|
Hello Dick,
of course i know how to write data to a file and show it in hex, but i
didnt see the TS showing that data. Only some typed values not being
representations of zoned numeric data. |
|
Back to top |
|
|
|