double

  • Thread starter Thread starter Peter Ramsebner
  • Start date Start date
P

Peter Ramsebner

Is there an explication why it's executed the then path?

Dim a As Double = 10
Dim b As Double = 3
Dim c As Double = 3
Dim x As Double
Dim y As Double = 10
x = a / b
x *= c
If x = y Then
Debug.Print("x")
End If

Peter
 
Peter said:
Is there an explication why it's executed the then path?

Dim a As Double = 10
Dim b As Double = 3
Dim c As Double = 3
Dim x As Double
Dim y As Double = 10
x = a / b
x *= c
If x = y Then
Debug.Print("x")
End If

Your Debug.Print should be outputting x.ToString and y.ToString.

Andrew
 
Your Debug.Print should be outputting x.ToString and y.ToString.

Forget the output, the question is how it is possible that x=y?
 
Debug.Print(3.3333333333333335 * 3) ' Which is 10it's not 10! It's 10,0000000005
 
Peter said:
it's not 10! It's 10,0000000005

Which probably 10 is also.

Most numbers can't be represented exactly as a decimal. There is really
no reason why 10 or 3 would be one of them.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top