java - Why does float print only up to 8 Digits? -
when printing below statement
system.out.println(121.3456422f);
i getting output 121.34564
(in 8 digits)
and if printing
system.out.println(121345642.333332f);
i getting output 1.2134564e8
(in 10 digits including e)
i want know why float 8 digits only?
the default conversion of float string produces shortest decimal fraction convert float on input. 8 decimal digits, because float has 24 bits of effective significand.
the exact value of 121.3456422f 121.34564208984375. largest float smaller 121.34563446044921875. 121.34564 between values , closer original value alternative, 8 enough digits.
Comments
Post a Comment