News for hackers. Stuff that matters.
Re:64-Bit Bank Balances ‘Ought to Be Enough for Anybody’? by bowsamic on Tuesday September 19, 2023 @08:31AM (#37569002)
I've never seen anyone use floating point for money in their bespoke applications
Re:64-Bit Bank Balances ‘Ought to Be Enough for Anybody’? by DamonHD on Tuesday September 19, 2023 @08:39AM (#37569091)
Every banking client did use double for the actual calculation phase of their derivatives trades.

(And some of our back-end systems then did ludicrous broken wrong-headed rounding to turn them into fictional currency values... Ho hum.)

Re:64-Bit Bank Balances ‘Ought to Be Enough for Anybody’? by __s on Tuesday September 19, 2023 @08:42AM (#37569116)
I worked on some software in the past where I converted double to C#'s decimal type. Unfortunately it wasn't so easy on the shop's old php stuff, but there I was more concerned with fixing their SQL injection issues rather than their rounding errors
Re:64-Bit Bank Balances ‘Ought to Be Enough for Anybody’? by atemerev on Tuesday September 19, 2023 @08:41AM (#37569105)
You _can_ use floating point if you are very careful and know what you are doing and know about decimal normalization (see e.g. OpenHFT implementation for high-frequency trading: https://github.com/OpenHFT/Chronicle-Core/blob/ea/src/main/j...)

But if you are not an expert, you better stick to BigDecimal and absorb the performance costs.

Re:64-Bit Bank Balances ‘Ought to Be Enough for Anybody’? by rvnx on Tuesday September 19, 2023 @09:04AM (#37569370)
Nice share! Interesting sorcery in their code:

> final double residual = df - ldf + Math.ulp(d) * (factor * 0.983);

Re:64-Bit Bank Balances ‘Ought to Be Enough for Anybody’? by MrBuddyCasino on Tuesday September 19, 2023 @08:37AM (#37569065)
Count yourself lucky.
Re:64-Bit Bank Balances ‘Ought to Be Enough for Anybody’? by zorked on Tuesday September 19, 2023 @08:49AM (#37569202)
Nubank used floating point - not in their real backend systems, but somewhere in their app. It was a bit amusing when people on Twitter found out certain very specific, arbitrary-looking amounts were not able to be transferred, then the computer scientists noticed what they had in common.
Re:64-Bit Bank Balances ‘Ought to Be Enough for Anybody’? by bradley13 on Tuesday September 19, 2023 @08:57AM (#37569287)
QuickBooks almost certainly used float in the early versions of their currency conversion. We saw lots of accumulated rounding errors that really couldn't be explained any other way.

That was maybe 15 years ago - hopefully they've fired that programmer and fixed it in the meantime. We don't know, because we don't use QuickBooks any more.