Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That is not enough.

Converting an amount to cents, e.g: $1.99 becomes 199 cents, will help you only briefly.

As numbers become larger or you have successive divisions, numbers will start to suffer from issues such as absorption. Then you may also suffer from issues when comparing numbers, since floating point equality is different.

e.g:

    > 1e16 -1
    10000000000000000
Note that this code should output 9999999999999999. But it doesn't because of absorption. In this case, "multiplying by a few thousands" makes this situation more likely.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: