+ 1

Comparison operator

Hey, could anyone help me and describe why is the code result false? Thank you. https://code.sololearn.com/cI3mPhE56HAd/?ref=app

2nd Feb 2019, 2:55 PM
Vlad The Fox
Vlad The Fox - avatar
1 Antwort
+ 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
Ipang