Comparison operator | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Comparison operator

Hey, could anyone help me and describe why is the code result false? Thank you.

2nd Feb 2019, 2:55 PM
Vlad The Fox
Vlad The Fox - avatar
1 Answer
+ 8
You are comparing a float type variable <f> with a double type literal (0.1), try `if(f == 0.1f)` this will compare <f> with a float type literal, and outputs "true".
2nd Feb 2019, 3:40 PM