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

COBOL variable is not getting rounded off


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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Aug 02, 2011 6:05 pm
Reply with quote

Hi enrico,

I can never find the "enormously heavy irony" smiley(!) when I need it :-)

I thought the OMG and ! would be enough.

I hope I haven't caused international panic. Have to be careful.

:-)
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Tue Aug 02, 2011 7:28 pm
Reply with quote

It is a very consistent result when you round each intermediate result :

do this :
R1 = (F-A-B-C-D-E) / (F-A)
R2 = R1 * G
R3 = R2 + H
R3'=round(R3,4)
=> this will give you your 'expected-by-you'-result

do this :
S1 = (F-A-B-C-D-E) / (F-A)
S1' = ROUND(S1,4)
s2 = S1' * G
S2' = round(S2,4)
S3 = S2' + H
==> this will give you your COBOL-result

depending on your compiler : sometimes it is round(intermediate,4) sometimes it is truncate(intermediate,4)
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 Goto page Previous  1, 2

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
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