3 ms·
After a cursory glance, is it me or is floating point being used? I thought this was something you wanted to avoid because of precision errors. ie 0.2 * 0.1
by Severian 7y ago
After a cursory glance, is it me or is floating point being used? I thought this was something you wanted to avoid because of precision errors.
ie 0.2 * 0.1
- uberneo 7y agoThis will work!! parseFloat((0.2 * 0.1).toFixed(10))
- treve 7y agoThe 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 https://www.npmjs.com/package/bigint-money