3 ms·
> No fucking floats <rant> Every time I see floats being used for stuff like currency, which is still more often than not, I'm reminded how very immature and u
by bowlofpetunias 13y ago
> No fucking floats
<rant>
Every time I see floats being used for stuff like currency, which is still more often than not, I'm reminded how very immature and unprofessional the business of programming still is. This situation has barely improved in the 25+ years I've been in IT.
For fuck sake, we're not talking "advanced" stuff like architecture, algorithms, unit testing, SOLID, or whatever, but basic use of simple tools that's equivalent to understanding that you don't use a hammer to drive in a screw.
I can't imagine any other profession where basic stuff is executed so cluelessly unless it's a deliberate scam.
Right now, as we speak, clients and/or employers are paying many thousands of dollars/euros/whatever to have brand new software build by programmers who will use floats for what are supposed to be exact amounts of money the core business of their employer/client depends on.
It's a pathetic state of affairs which makes the phrase "software is eating the world" an utterly terrifying idea.
And now there's a movement that wants to teach everyone "how to code".
The apocalypse will be caused by a rounding error.
</rant>
- louthy 13y agoIndeed. A useful discussion on this: http://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency http://stackoverflow.com/questions/3730019/why-not-use-doubl...
- kps 13y ago> This situation has barely improved in the 25+ years I've been in IT. Improved? 25+ years ago this would have been written in COBOL using decimal arithmetic as a matter of course — because 55 years ago the designers of COBOL knew better than to put floating point in a business language. (This is not a defense of COBOL, which is terrible in so many ways, because they didn't know much about programming in 1955 — but they knew they had to understand the problem domain.)
- bananacurve 13y agoIf we had evolved with only eight fingers we would be much better off. Also sometimes you do use a hammer to set a screw so it won't move when you go to drive it.
- ams6110 13y agoSo how does the latest darling of the webapp world, nodejs, handle this? In javascript, the only numeric type is float.
- bryanlarsen 13y agoThe same way you do it in Perl: you store rounded millicents. If there's never any fraction in your float, your math will never have floating point issues, and your Javascript VM will use integers internally.
- ZoFreX 13y ago> I can't imagine any other profession where basic stuff is executed so cluelessly unless it's a deliberate scam. Off the top of my head: Electricians. I've seen first-day-on-the-job-level mistakes in every single property I've rented. Most licensed electricians (nb: I am in the UK) don't seem to be able to safely wire a simple light switch.