How to write a logic for BANKERS ROUNDING in cobol



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

How to write a logic for BANKERS ROUNDING in cobol

Postby kolakumar » Sun Apr 16, 2017 12:40 am

Hi

How to handle BANKERS ROUNDING logic in cobol
kolakumar
 
Posts: 2
Joined: Sun Apr 16, 2017 12:36 am
Has thanked: 0 time
Been thanked: 0 time

Re: How to write a logic for BANKERS ROUNDING in cobol

 

Re: How to write a logic for BANKERS ROUNDING in cobol

Postby Robert Sample » Sun Apr 16, 2017 1:58 am

What have you tried so far? What is the specific problem you're having? This is a HELP forum, not a WRITE-THE-CODE-FOR-YOU forum. From what I can see from my Google search, the algorithm doesn't seem particularly difficult to implement.
Robert Sample
Global moderator
 
Posts: 3308
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 217 times

Re: How to write a logic for BANKERS ROUNDING in cobol

Postby prino » Sun Apr 16, 2017 1:59 am

By using PL/I, where the maintainers have just added a builtin (ROUNDTOEVEN) function requested by yours truly to do just that.

Or translate this to COBOL:

dcl rd fixed (9,5);

if (unspec(rd) & '000000fff0'bx) = '0000005000'bx then
if (unspec(rd) & '0000010000'bx) = '0000000000'bx then
rd = rd - 0.005;
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 520
Joined: Wed Mar 11, 2009 12:22 am
Location: Oostende, Belgium
Has thanked: 3 times
Been thanked: 19 times

Re: How to handle BANKERS ROUNDING in cobol

Postby kolakumar » Mon Apr 17, 2017 7:12 pm

Hi

Whether is there any possibility in COBOL to get this bankers rounding logic by changing any Inbuilt options?
kolakumar
 
Posts: 2
Joined: Sun Apr 16, 2017 12:36 am
Has thanked: 0 time
Been thanked: 0 time

Re: How to write a logic for BANKERS ROUNDING in cobol

Postby Robert Sample » Mon Apr 17, 2017 7:46 pm

Enterprise COBOL has no facility to do this. You MUST write code to implement it in COBOL.
Robert Sample
Global moderator
 
Posts: 3308
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 217 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post