I have some floating point number that i am obtaining. The number has strictly two decimal places and shall never be more than that.
I want to test if the number i have is a float and then make this two decisions.
If the number is equal to 5 but never greater than 5
If number is equal to 20 but never greater than 20 but never lesser than 5
I have this code
var get_sum = 4.45;
var dist = parseFloat(get_sum);
if(typeof(dist) == 'number' && dist == 5 || dist < 5){
}
if(typeof(dist) == 'number' && dist == 20 || dist < 20 && dist > 5){
}
Since i am dealing with floats me thinks ==
is a bad idea and i might get the wrong results.
Will my code always guarantee me correct results?.