+ 2

usage of F

Why this code doesnot run without F after 5.55? https://code.sololearn.com/cFrki4Aob1qS/?ref=app

8th Apr 2018, 11:56 AM
alireza
2 Answers
+ 7
Just because the compiler considers it to be of the 'double' data-type, thus there's a loss of data while implicit casting of a higher data-type (double) to a lower data-type (float). Using the character f or F tells the compiler that it is a floating point literal. Alternatively, you can do: float a = (float) 5.55;
8th Apr 2018, 12:02 PM
Dev
Dev - avatar
+ 3
De͏͏v Thank you very much
8th Apr 2018, 12:45 PM
alireza