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

Is it possible to round 9th decimal point in COBOL?


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

New User


Joined: 30 Apr 2009
Posts: 19
Location: chennai

PostPosted: Wed Jun 09, 2010 9:29 pm
Reply with quote

Hi,

Is it possible to round 9th decimal point while dividing values.

if the output of two values divide function is .093989466 that output value I want as .093989470 and if output is .093989464 that output value I want as .093989464.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Jun 09, 2010 9:36 pm
Reply with quote

Does ROUNDED not give you what you want?
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Wed Jun 09, 2010 9:39 pm
Reply with quote

Rounding 66 to 70 is inconsistent with rounding 64 to 64.
Did you mean 64 to 60?
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Wed Jun 09, 2010 9:51 pm
Reply with quote

If you used 'rounded' then the result is rounded.

You rounded the 10th significant digit into the 9th.

So maybe .093989466 was .0939894664 (notice the 10th digit in Bold) This was rounded down.

It could have been .0939894656 in which case it was rounded up.

Leaving the lengths of the significant digits the same and wanting to change the values is simply not correct.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jun 09, 2010 9:52 pm
Reply with quote

actually,
would it not be
66 to 7
and
64 to 6
????
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Wed Jun 09, 2010 10:02 pm
Reply with quote

It depends, in my example I described 10 digits to 9.

Your example would be for 9 digits to 8.

The OP has to tell us how many digits the end result should be.

My point is that if the end result should be 9 digits, and they used the rounded parameter, then they results are already correct.

I believe that they are try to perform additional rounding in their mind rather than trusting the computer to do its job.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jun 09, 2010 10:31 pm
Reply with quote

Quote:
I believe that they are try to perform additional rounding in their mind rather than trusting the computer to do its job.


yes dave, I agree,

this is a typical
'i want this'
regardless of how COBOL works.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Thu Jun 10, 2010 4:07 pm
Reply with quote

I'd say even if don't consider how COBOL does it, if one has used 'ROUNDED' then the result is rounded and that's just simple math. Whoever have "invented" "rounded" for COBOL must have used the basic math to write the underline-routine of "ROUNDED" and it won't give what you (vinuk2009) expect.

Probably, You (vinuk2009) just don't want to round off the digits - instead you need something totally different. If so, you should have used some other word to describe what you want in your subject line instead of the word "rounded"; with which we assume that you want what Dave has shown.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Thu Jun 10, 2010 4:11 pm
Reply with quote

Also, please answer what CG has pointed to - answer for that will make your problem better explained.
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 Replace each space in cobol string wi... COBOL Programming 2
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top