IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How can I remove trailing zeros from a Floating point data


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
anil.csk

New User


Joined: 22 Oct 2007
Posts: 16
Location: Noida

PostPosted: Fri Jun 06, 2008 4:32 pm
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Fri Jun 06, 2008 4:43 pm
Reply with quote

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
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Fri Jun 06, 2008 5:24 pm
Reply with quote

What does this have to do with floating point?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Jun 06, 2008 5:40 pm
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Fri Jun 06, 2008 7:03 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts Point and Shoot )PTNS TSO/ISPF 0
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top