[MLton-user] minor 32bit vs. 64bit differences in floating-point calculations with large numbers

David Hansel hansel at reactive-systems.com
Thu Oct 14 07:18:58 PDT 2010


Hi,

We have noticed that some calculations involving very large
"real" values produce different outputs when compiled with
64-bit MLton as opposed to 32-bit MLton (this is with MLton
Release 20100608, MinGW 32/64 build).

For example:

(1E308 * 10.0) / 10.0 = 1E308 when compiled as 32-bit
(1E308 * 10.0) / 10.0 = inf   when compiled as 64-bit

Is this a known issue?

My guess is that 32-bit MLton keeps the intermediate result
of this in the floating point registers (which support larger
values) but 64-bit MLton does not and therefore gets
1e308*10.0=inf => inf/10.0=inf

This is obviously a relatively minor issue as calculations
in such a high range should be generally avoided.  However it
can cause confusion when the same application behaves
differently between the two platforms.

David

-- 
  ----------------------------------------------------------
  David Hansel
  Chief Technology Officer -- Reactive Systems, Inc.
  http://www.reactive-systems.com/
  (919) 324-3507 ext. 102 -- hansel at reactive-systems.com
  OpenPGP (GnuPG) public key file:
  http://www.reactive-systems.com/~hansel/pgp_public_key.txt
  ----------------------------------------------------------



More information about the MLton-user mailing list