Hacker News new | ask | show | jobs
by zakpatterson 1780 days ago
Thanks for the write-up. I thought we would be protected because calculations are done using decimal places and then the final return is prepared using rounded integers.

But we have heard this a few times, so I think it would be good to make it explicit somewhere that it's done this way, or switch to bignumber. Do you think if all our calculations are done using decimal places, and then numbers are rounded to integer dollars on the final PDFs, that we'll still have errors?

Created an issue based on your feedback. Thank you! https://github.com/ustaxes/UsTaxes/issues/457

1 comments

the maximum safe integer in JS is 2^53 - 1. [0]

if you can find a way to use only integers within that range, you can do it safely in plain JS.

for example, units of integer microdollars (one millionth of a dollar) allows you to deal in amounts up to $9 billion without exceeding the safe integer limit. if you want a larger range than that, you need to make a corresponding reduction in precision (such as using millidollars).

or, switch to a full-blown bignum / arbitrary precision library.

0: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...