I think the following problem is a basic one in numerical codes:
Suppose that we would like to do a for loop
for (double x = 0; x < Y; x += dx)
{
// numeric code
}
The problem is that if we set dx=0.1
it is not exactly 1/10.
The last digit is usually bad,
and during the loop the error grows up.
If we fix Y, and want higher precision (decreasing dx)
means that the number of steps is increasing also.
If Y is in the order of magnitude 1 (unit),
dx = 1e-7 gives the highest precision (approximately)
because double is about 15 digits.
This is very bad!
Because this is only a simple loop,
and no numeric calculation has been done yet!
Are there any library to solve this problem?
Or can we set dx as exact double numbers?