Type check between integer and float type

Viewed 49

what is maximum precision check we do for float and integer ?

 0 === 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 

true // output 
2 Answers

Looking at:

> Number.MIN_VALUE
< 5e-324

Versus:

> '0.000--etc--0001'.length
< 487

We can see that your number is smaller than the allowable minimum non-zero float, so it gets rounded down to zero, making the expression effectively:

> 0 === 0.0
< true

Javascript, Typescript has the only type of Number. By default, you can not declare float type. But you check the float value. I think you have the answer here. here

Related