11-27-2018, 05:31 AM
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.
Original blog post: https://edspi31415.blogspot.com/2018/11/...nkers.html
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
002 INTG
003 STO 1
004 LSTx
005 FRAC
006 STO 2
007 .
008 5
009 -
010 x=0
011 GTO 018
012 RCL 0
013 FIX 0
014 RND
015 STO 4
016 FIX 2
017 GTO 000
018 RCL 1
019 2
020 ÷
021 FRAC
022 x=0
023 GTO 029
024 RCL 1
025 1
026 +
027 STO 4
028 GTO 000
029 RCL 1
030 STO 4
031 GTO 000
Original blog post: https://edspi31415.blogspot.com/2018/11/...nkers.html