Page 1 of 1

How to write a logic for BANKERS ROUNDING in cobol

PostPosted: Sun Apr 16, 2017 12:40 am
by kolakumar
Hi

How to handle BANKERS ROUNDING logic in cobol

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

PostPosted: Sun Apr 16, 2017 1:58 am
by Robert Sample
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.

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

PostPosted: Sun Apr 16, 2017 1:59 am
by prino
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;

Re: How to handle BANKERS ROUNDING in cobol

PostPosted: Mon Apr 17, 2017 7:12 pm
by kolakumar
Hi

Whether is there any possibility in COBOL to get this bankers rounding logic by changing any Inbuilt options?

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

PostPosted: Mon Apr 17, 2017 7:46 pm
by Robert Sample
Enterprise COBOL has no facility to do this. You MUST write code to implement it in COBOL.