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

> This suited me down to the ground because I pointed out to everybody that Javascript couldn't be guaranteed to treat numbers and calculations in a way that would keep the regulators auditors happy,

Javascript can represent dollar values up to $2.25 billion at a resolution of ten-thousandths of a cent without any loss of precision.

I would want all money calculations done by the backend team as a matter of policy. But it's not a technical limitation.



While you are correct that it can _represent_ these numbers with that precision... it cannot operate on them and retain that precision, so DO NOT USE FLOATS TO REPRESENT MONEY. Thank you for your time.

    let a = 35
    let b = -34.99

    console.log(a+b)

    // output: 0.00999999999999801


Brr almost got the shivers until I read your comment




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

Search: