Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Microsoft Access > Something wrong...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 11 Topic 30083 of 31576
Post > Topic >>

Something wrong adding numbers

by Guillermo_Lopez <g.lopez@[EMAIL PROTECTED] > Apr 24, 2008 at 04:23 PM

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.32699999

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 ac***ulative, 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
 




 11 Posts in Topic:
Something wrong adding numbers
Guillermo_Lopez <g.lop  2008-04-24 16:23:29 
Re: Something wrong adding numbers
"Rick Brandt" &  2008-04-24 18:34:39 
Re: Something wrong adding numbers
"Stuart McCall"  2008-04-25 01:22:43 
Re: Something wrong adding numbers
Guillermo_Lopez <g.lop  2008-04-25 13:44:56 
Re: Something wrong adding numbers
lyle fairfield <lyle.f  2008-04-25 15:05:16 
Re: Something wrong adding numbers
"Larry Linson"   2008-04-26 01:48:34 
Re: Something wrong adding numbers
Guillermo_Lopez <g.lop  2008-04-29 08:43:48 
Re: Something wrong adding numbers
CDMAPoster@[EMAIL PROTECT  2008-04-29 10:17:32 
Re: Something wrong adding numbers
lyle fairfield <lyle.f  2008-04-29 11:08:57 
Re: Something wrong adding numbers
CDMAPoster@[EMAIL PROTECT  2008-04-29 14:37:27 
Re: Something wrong adding numbers
Guillermo_Lopez <g.lop  2008-05-06 09:06:57 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 1:32:32 CST 2008.