Q:

Why does float print only up to 8 Digits?

When I am printing below statement 
System.out.println(121.3456422f);

I am getting output as 121.34564 (in 8 Digits) 
and if I am printing 
System.out.println(121345642.333332f);

I am getting output as 1.2134564E8 (in 10 Digits including E)
I want to know why float only up to 8 digits only?

A:

The default conversion of float to String produces the shortest decimal fraction that would convert back to the float on input. That will often be about 8 decimal digits, because float only has 24 bits of effective significand.
The exact value of 121.3456422f is 121.34564208984375. The largest float smaller than it is 121.34563446044921875. 121.34564 is between those values and closer to the original value than to the alternative, so 8 is enough digits.

