[Mono-dev] Simple floating maths problem
Robert Jordan
robertj at gmx.net
Fri Apr 30 07:33:55 EDT 2010
On 30.04.2010 00:21, Stuart Fraser wrote:
>
> Mono results:
> 0.95864 * 50000 = 47931
> 0.89374 * 50000 = 44686
> 0.89092 * 50000 = 44545
> 0.89716 * 50000 = 44857
> 0.4191 * 50000 = 20954
> 0.79782 * 50000 = 39890
>
> .Net results :
> 0.95864 * 50000 = 47932
> 0.89374 * 50000 = 44687
> 0.89092 * 50000 = 44546
> 0.89716 * 50000 = 44858
> 0.4191 * 50000 = 20955
> 0.79782 * 50000 = 39891
It's worth noting that MS.NET 32-bit (all versions) is returning
the same values as Mono does.
According to ECMA 335 (12.1.3 Handling of floating-point data types),
a CLI runtime may internally perform arithmetic operation with
higher range and/or precision.
Supposing that MS.NET's results for their 32-bit runtime
are correct (I doubt they aren't), the logical consequence
is that MS.NET 64-bit is performing floating point math
with a higher range/precision.
If you compare floating point results, you should compare them
using the least rest/precision dictated by the specs (IEC 60559:1989)
(7 digits for float32).
Robert
More information about the Mono-devel-list
mailing list