(12C) Banker's Rounding Method
|
11-27-2018, 05:31 AM
Post: #1
|
|||
|
|||
(12C) Banker's Rounding Method
The banker's rounding method involves rounding numeric amounts to the nearest integer. When the number ends in 0.5 (1.5, 3.5, 8.5, etc), special rules apply:
The decimal gets rounded to the nearest even integer. For example: 0.5, 2.5, and 4.5 round down to 0, 2, and 4 respectively. However, 1.5, 3.5, and 5.5 are rounded up to 2, 4, and 6 respectively. Code: 001 STO 0 Original blog post: https://edspi31415.blogspot.com/2018/11/...nkers.html |
|||
11-27-2018, 06:42 PM
(This post was last modified: 12-08-2018 08:46 PM by Albert Chan.)
Post: #2
|
|||
|
|||
RE: (12C) Banker's Rounding Method
I think banker's rounding method apply to non-integers too (edge case round-to-even).
For banker's rounding to nearest integer, this is shorter Code: 01 . Example: 1233.5 R/S ==> 1234 1233.9 R/S ==> 1234 1234.5 R/S ==> 1234 1233.49 R/S ==> 1233 1234.51 R/S ==> 1235 Updated: code numbering start from 1, instead of 0 |
|||
12-08-2018, 08:35 PM
Post: #3
|
|||
|
|||
RE: (12C) Banker's Rounding Method
Just a slight correction since the code starts at line 1, not 0:
Code: 01 . Otherwise, brilliant! |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)