console.log(0.1 + 0.2 == 0.3); True
console.log(0.1 + 0.2)=0.30000000000000004 & console.log(0.1 + 0.2 == 0.3)=false
console.log(0.1 0.2)=0.300000000004 and console.log(0.1 0.2==0.3)= false
1. 0.10.2 2. false
1. 0.30000000004 2. false
Read once more :: An educated answer to this question would simply be: “You can't be sure. it might print out “0.3” and “true”, or it might not. Numbers in JavaScript are all treated with floating point precision, and as such, may not always yield the expected results.”The example provided above is classic case that demonstrates this issue. Surprisingly, it will print out: 0.30000000000000004
Also 0.1 + 0.2 == 0.3, This is also false, Because here it doesn't indicating typeOf check, Its totally different in floating point numbers.
alert(a == b);alert(a === b);"==" refers to equals check, while "===" also checks type.I think you made it wrong Abrar. What the question is... 0.2 +0.1 === 0.30000000000000004, Why? I know, everything in JS is object.
0.30000000000000004 false see below exmple. var a = "01"; var b = 01; alert(a == b) //object comparing ; alert(a === b) //object type comparing; output true false
Amazing question, and answer is also surprising. An educated answer to this question would simply be: “You can't be sure. it might print out “0.3” and “true”, or it might not. Numbers in JavaScript are all treated with floating point precision, and as such, may not always yield the expected results.”The example provided above is classic case that demonstrates this issue. Surprisingly, it will print out: 0.30000000000000004