View Single Post
  #5  
Old November 14th, 2009, 01:08 PM posted to microsoft.public.excel.misc
Jerry W. Lewis
external usenet poster
 
Posts: 491
Default Something is not right

So no one misinterprets your statement, results are not random. When
evaluating a complicated expression, intermediate results are produced. The
final result of the calculation depends on the storage precision for those
intermediate results, which can depend on the implementation.

For instance, in VBA, if all variables in the calculation are explicitly
declared double, then intermediate results appear to be stored in the 10-byte
extended precision of the math processor. In the following VBA code, the
only difference between the calculations for c and cd are that the variables
contributing to cd are explicitly double. Without extended precision
intermediate storage, the multiplication underflows to zero, before the
division brings it back into double precision range.

Sub tryit()
Dim a, b, ad As Double, bd As Double
a = 1E-300: b = 1E-30: ad = 1E-300: bd = 1E-300:
c = a * b / a
cd = ad * bd / ad
MsgBox (c & " " & cd)
End Sub

Jerry

"Joe User" wrote:
....
[1] What the "binary arithmetic computation permits" can vary from one
implementation to another, even on the same computer. This is why
occassionally Excel and VBA will have different results for the same
expression.

....