Here\'s the code:
typedef std::numeric_limits fl;
int main()
{
std::cout.precision(100);
float f1 = 9999978e3;
std::cout &l
Not in the way you think it's guaranteed, no.
By way of offering a counter-example, for an IEEE754 single precision floating point, the closest number to
9999990000
is
9999989760
What is guaranteed is that your number and the float
, when both are rounded to six significant figures, will be the same. This is be the value of FLT_DIG
on your platform, assuming it implements IEEE754. E.g. the closest float
number to 9999979000
is 9999978496
.
See http://www.exploringbinary.com/floating-point-converter/