[MLton-commit] r7296
Wesley Terpstra
wesley at mlton.org
Tue Oct 20 08:27:45 PDT 2009
Improve the test to distinguish denormalized precision from normal precision.
----------------------------------------------------------------------
U mlton/trunk/regression/real-basic.ok
U mlton/trunk/regression/real-basic.sml
U mlton/trunk/regression/real-basic.x86-darwin.ok
U mlton/trunk/regression/real-basic.x86-freebsd.ok
U mlton/trunk/regression/real-basic.x86-linux.ok
----------------------------------------------------------------------
Modified: mlton/trunk/regression/real-basic.ok
===================================================================
--- mlton/trunk/regression/real-basic.ok 2009-10-20 14:50:23 UTC (rev 7295)
+++ mlton/trunk/regression/real-basic.ok 2009-10-20 15:27:43 UTC (rev 7296)
@@ -2,31 +2,31 @@
Reported
precision: 24
max exponent: 128
- min exponent: ~148
- subnormal: yes
+ min exponent: ~125
+ min denormal: ~148
Actual
precision: 24
max exponent: 128
- min exponent: ~148
- subnormal: yes
+ min exponent: ~125
+ min denormal: ~148
Exported
precision: 24
max exponent: 128
- min exponent: ~148
- subnormal: yes
+ min exponent: ~125
+ min denormal: ~148
Real64
Reported
precision: 53
max exponent: 1024
- min exponent: ~1073
- subnormal: yes
+ min exponent: ~1021
+ min denormal: ~1073
Actual
precision: 53
max exponent: 1024
- min exponent: ~1073
- subnormal: yes
+ min exponent: ~1021
+ min denormal: ~1073
Exported
precision: 53
max exponent: 1024
- min exponent: ~1073
- subnormal: yes
+ min exponent: ~1021
+ min denormal: ~1073
Modified: mlton/trunk/regression/real-basic.sml
===================================================================
--- mlton/trunk/regression/real-basic.sml 2009-10-20 14:50:23 UTC (rev 7295)
+++ mlton/trunk/regression/real-basic.sml 2009-10-20 15:27:43 UTC (rev 7296)
@@ -7,9 +7,10 @@
val () = print (" precision: " ^ Int.toString precision ^ "\n")
val {man=_, exp} = toManExp maxFinite
val () = print (" max exponent: " ^ Int.toString exp ^ "\n")
+ val {man=_, exp} = toManExp minNormalPos
+ val () = print (" min exponent: " ^ Int.toString exp ^ "\n")
val {man=_, exp} = toManExp minPos
- val () = print (" min exponent: " ^ Int.toString exp ^ "\n")
- val () = print (" subnormal: yes\n")
+ val () = print (" min denormal: " ^ Int.toString exp ^ "\n")
(* Now let's compute the actual mantissa *)
val zero = fromInt 0
@@ -19,38 +20,43 @@
fun precision eq x =
if eq (x+one, x) then 0 else
Int.+ (1, precision eq (x+x))
- fun maxExp inf x =
- if inf (x+x) then 1 else
- Int.+ (1, maxExp inf (x+x))
- fun minExp zero x =
- if zero (x / two) then 1 else
- Int.- (minExp zero (x / two), 1)
- fun deNorm zero =
- if zero (minPos * (one + one / two) - minPos) then "no" else "yes"
+ fun maxExp eq x =
+ if eq (x, x+x) then 0 else
+ Int.+ (1, maxExp eq (x+x))
+ fun lowBit (1, x) = x
+ | lowBit (i, x) = lowBit (Int.- (i, 1), x / two)
+ fun minExp eq x =
+ if not (eq (x, (x / two) * two)) orelse eq (x, zero) then 1 else
+ Int.- (minExp eq (x / two), 1)
- val xprecision = precision == one
- val xmaxExp = maxExp (not o isFinite) one
- val xminExp = minExp (fn z => == (z, zero)) one
- val xdeNorm = deNorm (fn z => == (z, zero))
+ val eq = ==
+ val xprecision = precision eq one
+ val lastBit = one + lowBit (xprecision, one)
+ val xmaxExp = maxExp eq one
+ val xminNormalExp = minExp eq lastBit
+ val xminExp = minExp eq one
val () = print " Actual\n"
val () = print (" precision: " ^ Int.toString xprecision ^ "\n")
val () = print (" max exponent: " ^ Int.toString xmaxExp ^ "\n")
- val () = print (" min exponent: " ^ Int.toString xminExp ^ "\n")
- val () = print (" subnormal: " ^ xdeNorm ^ "\n")
+ val () = print (" min exponent: " ^ Int.toString xminNormalExp ^ "\n")
+ val () = print (" min denormal: " ^ Int.toString xminExp ^ "\n")
val a = Word8Array.array (Pack.bytesPerElem, 0w0)
fun id x = (Pack.update (a, 0, x); Pack.subArr (a, 0))
- val xprecision = precision (fn (x, y) => == (id x, id y)) one
- val xmaxExp = maxExp (not o isFinite o id) one
- val xminExp = minExp (fn z => == (id z, zero)) one
- val xdeNorm = deNorm (fn z => == (id z, zero))
+ val eq = fn (x, y) => == (id x, id y)
+ val xprecision = precision eq one
+ val lastBit = one + lowBit (xprecision, one)
+ val xmaxExp = maxExp eq one
+ val xminNormalExp = minExp eq lastBit
+ val xminExp = minExp eq one
+
val () = print " Exported\n"
val () = print (" precision: " ^ Int.toString xprecision ^ "\n")
val () = print (" max exponent: " ^ Int.toString xmaxExp ^ "\n")
- val () = print (" min exponent: " ^ Int.toString xminExp ^ "\n")
- val () = print (" subnormal: " ^ xdeNorm ^ "\n")
+ val () = print (" min exponent: " ^ Int.toString xminNormalExp ^ "\n")
+ val () = print (" min denormal: " ^ Int.toString xminExp ^ "\n")
end
val () = print "Real32\n"
Modified: mlton/trunk/regression/real-basic.x86-darwin.ok
===================================================================
--- mlton/trunk/regression/real-basic.x86-darwin.ok 2009-10-20 14:50:23 UTC (rev 7295)
+++ mlton/trunk/regression/real-basic.x86-darwin.ok 2009-10-20 15:27:43 UTC (rev 7296)
@@ -2,31 +2,31 @@
Reported
precision: 24
max exponent: 128
- min exponent: ~148
- subnormal: yes
+ min exponent: ~125
+ min denormal: ~148
Actual
precision: 64
max exponent: 128
min exponent: ~149
- subnormal: yes
+ min denormal: ~149
Exported
precision: 24
max exponent: 128
- min exponent: ~148
- subnormal: no
+ min exponent: ~149
+ min denormal: ~149
Real64
Reported
precision: 53
max exponent: 1024
- min exponent: ~1073
- subnormal: yes
+ min exponent: ~1021
+ min denormal: ~1073
Actual
precision: 64
max exponent: 1024
min exponent: ~1074
- subnormal: yes
+ min denormal: ~1074
Exported
precision: 53
max exponent: 1024
- min exponent: ~1073
- subnormal: no
+ min exponent: ~1074
+ min denormal: ~1074
Modified: mlton/trunk/regression/real-basic.x86-freebsd.ok
===================================================================
--- mlton/trunk/regression/real-basic.x86-freebsd.ok 2009-10-20 14:50:23 UTC (rev 7295)
+++ mlton/trunk/regression/real-basic.x86-freebsd.ok 2009-10-20 15:27:43 UTC (rev 7296)
@@ -2,31 +2,31 @@
Reported
precision: 24
max exponent: 128
- min exponent: ~148
- subnormal: yes
+ min exponent: ~125
+ min denormal: ~148
Actual
precision: 64
max exponent: 128
min exponent: ~149
- subnormal: yes
+ min denormal: ~149
Exported
precision: 24
max exponent: 128
- min exponent: ~148
- subnormal: no
+ min exponent: ~149
+ min denormal: ~149
Real64
Reported
precision: 53
max exponent: 1024
- min exponent: ~1073
- subnormal: yes
+ min exponent: ~1021
+ min denormal: ~1073
Actual
precision: 64
max exponent: 1024
min exponent: ~1074
- subnormal: yes
+ min denormal: ~1074
Exported
precision: 53
max exponent: 1024
- min exponent: ~1073
- subnormal: no
+ min exponent: ~1074
+ min denormal: ~1074
Modified: mlton/trunk/regression/real-basic.x86-linux.ok
===================================================================
--- mlton/trunk/regression/real-basic.x86-linux.ok 2009-10-20 14:50:23 UTC (rev 7295)
+++ mlton/trunk/regression/real-basic.x86-linux.ok 2009-10-20 15:27:43 UTC (rev 7296)
@@ -2,31 +2,31 @@
Reported
precision: 24
max exponent: 128
- min exponent: ~148
- subnormal: yes
+ min exponent: ~125
+ min denormal: ~148
Actual
precision: 64
max exponent: 128
min exponent: ~149
- subnormal: yes
+ min denormal: ~149
Exported
precision: 24
max exponent: 128
- min exponent: ~148
- subnormal: no
+ min exponent: ~149
+ min denormal: ~149
Real64
Reported
precision: 53
max exponent: 1024
- min exponent: ~1073
- subnormal: yes
+ min exponent: ~1021
+ min denormal: ~1073
Actual
precision: 64
max exponent: 1024
min exponent: ~1074
- subnormal: yes
+ min denormal: ~1074
Exported
precision: 53
max exponent: 1024
- min exponent: ~1073
- subnormal: no
+ min exponent: ~1074
+ min denormal: ~1074
More information about the MLton-commit
mailing list