View previous topic :: View next topic
|
Author |
Message |
anil.csk
New User
Joined: 22 Oct 2007 Posts: 16 Location: Noida
|
|
|
|
How can I remove trailing zeros from floating point data. In COBOL I've done this with referential modification. I want to know any simpler method.
After the decimal point data can be up to six digits. Here I'm taking the example up to there digist after decimal point:
example..
data is: 234.120
I want to represent as 234.12
if data is 234.100
then I want to represent as 234.1
f 234.001
then I want to represent as 234.001
if 234.010
then I want to represent as 234.01 |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Simple. Assuming the data has been moved to an edited-pattern (as you've illustrated), begin at the last byte and test each byte (while moving backwards) for NUMERIC and ZERO, until the given tested-byte is NUMERIC and non-ZERO. You can put this in an in-line "PERFORM" loop.
You'll also have to make accommodations for the "period".
Bill |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
What does this have to do with floating point? |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Bill O'Boyle wrote: |
Simple. Assuming the data has been moved to an edited-pattern (as you've illustrated), begin at the last byte and test each byte (while moving backwards) for NUMERIC and ZERO, until the given tested-byte is NUMERIC and non-ZERO. You can put this in an in-line "PERFORM" loop.
You'll also have to make accommodations for the "period".
Bill |
until the given tested-byte is NOT NUMERIC OR (NUMERIC and non-ZERO).
It has nothing to do with floating point. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Craig,
In my post, I had made a SWAG that the floating-point number had been moved to an edit-pattern, because this is what was illustrated.
Yes, COMP-1 and/or COMP-2 Floating-Point values are a different animal from any other format.
Bill |
|
Back to top |
|
|
|