Hello All,
I am using VBA in access to perform some calculations. There is a
particular sumation that is wrong (barely).
this code is withing a loop.
TDist = TDist + TempDist
Both TDist and TempDist are declared as doubles:
Dim TDist As Double
Dim TempDist As Double
After looping through 7000+ iterations the following addition produces
this result
These are the exact values of the variables:
TDist = 6388254.993
TempDist = 36.334
When: TDist = TDist + TempDist
TDist = 6388291.3269999 9
TDist is suppose to be 6388291.327
Although the difference is negligable and a simple Format would fix
it. I noticed it only happened here, I can't reproduce it in the
Immediate window.
I am worried if it's going to generate a much larger error. And when
its accumulative, it tends to grow errors like this, especially when
running 200k iterations or more.
Is this something anybody has experienced?
Is there a solution to prevent this error?
Or is this just some highly unlikely situation that occured to me for
a very remote and Highly Unlikely combination of data? (Sounds alot
like Douglas Adams)
- GL
I am using VBA in access to perform some calculations. There is a
particular sumation that is wrong (barely).
this code is withing a loop.
TDist = TDist + TempDist
Both TDist and TempDist are declared as doubles:
Dim TDist As Double
Dim TempDist As Double
After looping through 7000+ iterations the following addition produces
this result
These are the exact values of the variables:
TDist = 6388254.993
TempDist = 36.334
When: TDist = TDist + TempDist
TDist = 6388291.3269999 9
TDist is suppose to be 6388291.327
Although the difference is negligable and a simple Format would fix
it. I noticed it only happened here, I can't reproduce it in the
Immediate window.
I am worried if it's going to generate a much larger error. And when
its accumulative, it tends to grow errors like this, especially when
running 200k iterations or more.
Is this something anybody has experienced?
Is there a solution to prevent this error?
Or is this just some highly unlikely situation that occured to me for
a very remote and Highly Unlikely combination of data? (Sounds alot
like Douglas Adams)
- GL
Comment