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
You could just limit the precision of the float. If you are writing banking software or something you could just add a special case to flip flop the remainder or something. I think pretty much all modern languages support this. You should also be using doubles for any numbers that could potentially grow really large like fiat currencies. The issues with floats really is that it will often favor precision over range. You could end up with lots of numbers after a decimal and very little integer range which could cause overruns or something.
The article goes into depth about what you should be using. Floats and doubles are not designed for use with base 10 fractions. They're good at estimating them, but not accurate enough for real financial use.
There's also not much reason to reinvent the wheel for an already solved problem. Many languages have this data type already built into the language, and the rest usually have it available through a package.
Oh nice I'm far from a professional programmer. Thxs for the explanation.