Reputation: 53037
Finance applications demand an integer type due to security reasons. Rounding errors are not acceptable in that kind of application and can lead to exploits. Since JavaScript doesn't offer a proper Integer type, only IEEE 754 Doubles, how do you deal with monetary values in JavaScript, while keeping it safe?
Upvotes: 0
Views: 121
Reputation: 26185
IEEE 754 64-bit binary floating point can represent exactly every integer with magnitude no greater than 2^53. That means you can represent exactly, as an integer number of cents, every money amount with magnitude no greater than $90,071,992,547,409.92. For comparison, the US National Debt is currently about $16,787,451,118,147.
Upvotes: 2