this post was submitted on 24 Sep 2025
100 points (97.2% liked)
Programming
22883 readers
237 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 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
That doesn't make any sense. As you say, in that case you have to "spread leftovers", but that isn't really any more difficult with floats than integers.
It's better to use integers, sure. But you're waaaay over-blowing the downsides of floats here. For 99% of uses
f64
will be perfectly fine. Obviously don't run a stock exchange with them, but think about something like a shopping cart calculation or a personal finance app. Floats would be perfectly fine there.As someone who has implemented shopping carts, invoicing solutions and banking transactions I can assure you floats will be extremely painful for you.
A huge benefit of big decimals is that they don't allow you to make a mistake (as easily) as floats where imprecision just "creeps in".
As you said, better use integers. And that's exactly what is done at this point.
Indeed, but there's no need to shit on people using floats because in almost all cases they are fine too.
Where the heck did I "shit on people using floats"?