It might also depend on your floating point options... as there are options to select between faster computation or more precise one (IEEE).
That being said, I have made a small test program
int i = 0;
float f = 0.601626;
double a = 1.0;
double b = a + f;
while (a < b)
{
a *= 1.1;
b = a + f;
++i;
}
That program fails after 386 iterations. At that point a is equal to
9 496 782 049 180 368.0
Thus it actually fails somewhere between 8.6e15 and 9.5e15 when adding 0.601626 to a
double
.
By the way 2^53 is equal to 9.001e15 (and it would probably fail at that point... Also a lot of imprecision would have been added if the additions are cumulatives).
Thus, I don't understand why the program does not works as expected as the OP numbers are around a million time smaller than that...
Also, how do you actuall print that number
12966127670.788626
as it has more than 15 significant digits so that number... Last 2 digits are probably incorrect. Are those values printed or inspected from code or the second value is what you think it should be.
By the way, are you always adding
0.601626
and in particular when it fails? And are you computation as simple as a simple addition. If they are somehow more complex (and you have inspected
b
, then there might some rounding errors you havent noticed).
Finally be aware that values printed are rounded so there can be a difference in the actual float value and what is displayed if you display 15 or more digits.
*** In you case, you might consider using 64 bits integers everywhere to avoid loosing some precision ***.