logoalt Hacker News

fragmedelast Saturday at 7:57 PM2 repliesview on HN

"Monetary value must be stored in integers" is the much stronger statement that the article doesn't make. Obviously there are exceptions, but you're going to need a much longer side discussion in order to justify why you're using floats.

It's like saying "don't write your own crypto algorithm". Of course write your own crypto algorithm, that's how you learn about cryptography. But you'd never put your homegrown cryptographic algorithm into production until after several PhDs worth of understanding of cryptography has been put into it by many other people.


Replies

fauigerzigerklast Sunday at 12:04 PM

>"Monetary value must be stored in integers" is the much stronger statement that the article doesn't make. Obviously there are exceptions, but you're going to need a much longer side discussion in order to justify why you're using floats.

It doesn't make that statement because arbitrary precision decimals exist. Binary float is not the only and not the most plausible alternative to using integers.

Eremlast Sunday at 1:49 AM

If you render a number using JavaScript it has been temporarily stored as a doublr. The article was likely allowing for that common use case.

show 1 reply