DEV Community

Discussion on: How to Compare Decimals in JavaScript

Collapse
 
lexlohr profile image
Alex Lohr

The problem here is that all numbers in JS are IEEE 754 64 bit numbers (1 bit sign, 11 bit exponent, 52 bit mantissa). Allowing for imprecision will solve the false negative, but will increase the chance of false positives at the same time.

A better solution would be to go beyond this number format and use something like big.js instead.