Trev13@programming.dev to Programming@programming.dev · 2 days agoBig Decimals: Stop Using Floats or Cents for Moneymedium.comexternal-linkmessage-square53fedilinkarrow-up187arrow-down13
arrow-up184arrow-down1external-linkBig Decimals: Stop Using Floats or Cents for Moneymedium.comTrev13@programming.dev to Programming@programming.dev · 2 days agomessage-square53fedilink
minus-squarebleistift2@sopuli.xyzlinkfedilinkEnglisharrow-up1arrow-down2·edit-22 days agoIf you count the programming language you use as ‘platform’, then yes. Python rounds both 11.5 and 12.5 to 12.
minus-squareFizzyOrange@programming.devlinkfedilinkarrow-up2·1 day agoThat is default IEEE behaviour: https://en.wikipedia.org/wiki/Rounding#Rounding_half_to_even This is the default rounding mode used in IEEE 754 operations for results in binary floating-point formats. Though it’s definitely a bad default because it’s so surprising. Javascript and Rust do not do this. Not really anything to do with determinism though.
minus-squareWolfLink@sh.itjust.workslinkfedilinkarrow-up4·2 days agoThis is a common rounding strategy because it doesn’t consistently overestimate like the grade school rounding strategy of always rounding up does.
If you count the programming language you use as ‘platform’, then yes. Python rounds both 11.5 and 12.5 to 12.
That is default IEEE behaviour: https://en.wikipedia.org/wiki/Rounding#Rounding_half_to_even
Though it’s definitely a bad default because it’s so surprising. Javascript and Rust do not do this.
Not really anything to do with determinism though.
This is a common rounding strategy because it doesn’t consistently overestimate like the grade school rounding strategy of always rounding up does.