Hacker News new | ask | show | jobs
by uberneo 2515 days ago
This will work!!

parseFloat((0.2 * 0.1).toFixed(10))

1 comments

The issue is more obvious when rounding something like 0.5, which, due to lack of precision can become either 0 or 1.

Shameless plug: use https://www.npmjs.com/package/bigint-money