this post was submitted on 24 Sep 2025
92 points (96.9% liked)
Programming
27841 readers
747 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities !webdev@programming.dev
founded 3 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Single floats sure, but doubles give plenty of accuracy unless you absolutely need zero error.
For example geting 1000 random 12 digit ints, multiplying them by 1e9 as floats, doing pairwise differences between them and summing the answers and dividing by 1e9 to get back to the ints gives a cumulative error of 1 in 10^16. assuming your original value was in dollars thats roughly 0.001cent in a billion dollar total error. That's going deliberately out of the way to make transactions as perverse as possible.
Nope. With about a hundred thousand factored items, things easily run off the rails. I've seen it. Just count cents, and see that rounding errors are kept in close, deterministic confines.
You can use Kahan summation to mitigate floating point errors. A mere 100 thousand floating point operations is a non-issue.
As a heads up computational physics and mathematics tackle problems trillions of times larger than any financial computation, that's were tons of algorithms have been developed to handle floating point errors. Infact essentially any large scale computation specifically accounts for it.
Yeah, but compared to counting money, nobody cares if some physics paper got its numbers wrong. :-)
(Not to mention that would require the paper to have reproducible artifacts first.)
We're using general relativity to calculate sattelite orbits - fuck your point of sale system if our sattelites come crashing down we're gonna have much bigger problems lol.
Physics modeling is arguably the most important task of computers. That was the original impetus for building them; artillery calculations in WW2.
All engineering modeling uses physics modeling, almost always linear algebra (which involves large summations). Nuclear medicine—physics, weather forecasting—physics, molecular dynamics and computational chemistry—physics.
Physics modeling is the backbone of modern technology, it's why so much research has been done on doing it efficiently and accurately.