3 ms·
I've never seen anyone use floating point for money in their bespoke applications
by bowsamic 3y ago
I've never seen anyone use floating point for money in their bespoke applications
- MrBuddyCasino 3y agoCount yourself lucky.
- DamonHD 3y agoEvery 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.)
- atemerev 3y agoYou _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/java/net/openhft/chronicle/core/Maths.java 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.
- rvnx 3y agoNice share! Interesting sorcery in their code: > final double residual = df - ldf + Math.ulp(d) * (factor * 0.983);
- __s 3y agoI 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
- zorked 3y agoNubank 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.
- bradley13 3y agoQuickBooks 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.