## 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

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

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: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

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

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

prino

Posts: 639
Joined: Wed Mar 11, 2009 12:22 am
Location: Vilnius, Lithuania
Has thanked: 3 times
Been thanked: 29 times

### Re: How to handle BANKERS ROUNDING in cobol

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

Enterprise COBOL has no facility to do this. You MUST write code to implement it in COBOL.
Robert Sample
Global moderator

Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times