New course! Every coder should learn Generative AI!
Try a free lesson0
Why it is 'not equal'?
2 Answers
+ 1
u need to write
f1 = 0.1f
if(f1 == 0.1f)
+ 1
It's a bit complicated, but float gets converted to double and becomes a slightly different down the line.
When working with floats, add 'f' at the end of numbers, i.e.: 0.1f. That way it won't be converted back and forth and cause issues like that.