The code itself is flawed where it uses %f
for a value larger than significance held in a float
or double
. By doing so you are asking to see "behind the curtain" as to the meaningless guard bits or other floating point noise generated in the conversion to decimal.
Clearly you should not expect any consistency in the metal filings generated after making an engine at Honda versus at Toyota. Nevermind any sensible expectation of such consistency.
The proper way to display such numbers is by using one of the "scientific" formats such as %g
provided precision is not over-specified. On IEEE-754 implementations, 7 decimal figures are significant for float
, 15-16 for double
, about 19 for long double
, and 34 for __float128
. So, for the example you have given, %.15g
would be proper, assuming it is on a IEEE-754 implementation.