Thread: Round off error
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
harvey harvey is offline
external usenet poster
 
Posts: 24
Default Round off error

Sorry! my mistake I forgot to write that step now if you run it you won't get
0 as you expect!! instead very very small number how can we modify the code
to eliminate this error.
Thanks :)

"Vergel Adriano" wrote:

Harvey,

I'm not sure of what you mean by "eliminate roundoff" and what you expect
the loop to do, but the way you have it, it will go through the loop only
once and that's for the first value of -0.2. The next value will be 0.8
which is 0.2. If you specify a step value, you'll get more iterations:

Dim i As Double
For i = -0.2 To 0.2 Step 0.1
Debug.Print i
Next


"Harvey" wrote:

Anyone knows how to eliminate roundoff error in a loop?

Dim i as double
for i= - 0.2 to 0.2
debug.print i
next

Thanks:)