0

Calculating if the modulus of a number is 0 to find if the number is whole works up until 15 decimal places is exceeded.

What makes 0.9999999999999999 diferent from 0.99999999999999999

function isInteger(n) {
    return n % 1 === 0;
}

isInteger(0.9); //false
isInteger(0.99999999999999999); //true?

Here's a jsFiddle example

Why is this?

Community
  • 1
  • 1
Perbert
  • 465
  • 1
  • 7
  • 17

0 Answers0