Because floating point numbers are by default of type double
. To make it a float you append an F
. You are getting error in the below assignment:
float f = 3.4028235E38;
because a double as more precision than a float. So, there is a possible loss of precision.
I would have expected just the opposite as floating point literals are by default double and should be more precise.
Let's check the binary representation of your number till double precision:
0x47EFFFFFE54DAFF8 = 01000111 11101111 11111111 11111111
11100101 01001101 10101111 11111000
Now since float
is a single precision 32-bit floating point value. It can't store all the double values, which are double precision 64-bit floating point values.