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 All times are GMT + 6 Hours
Forum Index -> COBOL Programming Goto page Previous  1, 2

 


Similar Topics
Topic Forum Replies
No new posts IBM IMU Utility for Easytrieve Code t... IBM Tools 0
No new posts Big Five Personality Test in COBOL - ... COBOL Programming 0
No new posts I wrote a Hallmark Movie Plot Generat... COBOL Programming 0
No new posts COBOL Text Adventure Engine for TK4- ... COBOL Programming 0
No new posts Cobcalc: An Algebraic Expression Eval... COBOL Programming 10
Search our Forums:


Back to Top