Strange Multiplication Rounding Results in .NET 1.1

  • Thread starter Thread starter bcumminsr
  • Start date Start date
B

bcumminsr

Hi, Does anyone have any idea why in the immediate window in Microsoft
Development Environment 2003 version 7.1 that ?240*4.1 =
983.99999999999989? I know that math.round() will correct... but these
results seem crazy. Any ideas?

Thanks,
Ben
 
Well, quite normal since 4.1 has no exact binary representation (which is
used by the computer for the calculation). Multiplying a not so exact number
will show the rounding errors.

For a test: take any fractional number and multiply it with 2 until it
becomes an integer number. If ths is possible and the eesult has less than
28 digits (well - this is oversimplified but I think you get the point) an
exact binary representation is possible. You can multiply 4.1 with 2 as long
as you want without reaching this goal. 4.125 would be precise (*2 *2 *2 =
33).

Have Fun

Jochen
 
Back
Top