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 COBOL sorting, with input GDG base COBOL Programming 7
No new posts Need help with ADABAS query (COBOL-AD... All Other Mainframe Topics 0
No new posts REXX/CMS How to place command console... CLIST & REXX 4
No new posts Replacing FILLER with FILLER<SeqNu... DFSORT/ICETOOL 2
No new posts Compile Sp Cobol base COBOL Programming 1
Search our Forums:

Back to Top