ref: 66a472dc689c3a7b2b8f077fdf01c0dc2fdc1f7d
parent: 3853fa79b7d297f4bd3aaf318a147a95dd088bc9
author: S. Gilles <[email protected]>
date: Thu May 10 06:42:25 EDT 2018
Use x as input variable instead of f. Some algorithm descriptions use f as an auxiliary variable. Since we attempt to match variable naming to the relevant algorithm description, this becomes a problem. For uniformity, change everywhere.
--- a/lib/math/exp-impl.myr
+++ b/lib/math/exp-impl.myr
@@ -10,15 +10,15 @@
enough to be in the same function.
*/
pkg math =
- pkglocal const exp32 : (f : flt32 -> flt32)
- pkglocal const exp64 : (f : flt64 -> flt64)
+ pkglocal const exp32 : (x : flt32 -> flt32)
+ pkglocal const exp64 : (x : flt64 -> flt64)
- pkglocal const expm132 : (f : flt32 -> flt32)
- pkglocal const expm164 : (f : flt64 -> flt64)
+ pkglocal const expm132 : (x : flt32 -> flt32)
+ pkglocal const expm164 : (x : flt64 -> flt64)
;;
-extern const horner_polyu32 : (f : flt32, a : uint32[:] -> flt32)
-extern const horner_polyu64 : (f : flt64, a : uint64[:] -> flt64)
+extern const horner_polyu32 : (x : flt32, a : uint32[:] -> flt32)
+extern const horner_polyu64 : (x : flt64, a : uint64[:] -> flt64)
type fltdesc(@f, @u, @i) = struct
explode : (f : @f -> (bool, @i, @u))
@@ -50,7 +50,6 @@
L1 : @u
L2 : @u
S : (@u, @u)[32]
-
;;
const desc32 : fltdesc(flt32, uint32, int32) = [
@@ -194,18 +193,18 @@
.precision = 53,
]
-const exp32 = {f : flt32
- -> expgen(f, desc32)
+const exp32 = {x : flt32
+ -> expgen(x, desc32)
}
-const exp64 = {f : flt64
- -> expgen(f, desc64)
+const exp64 = {x : flt64
+ -> expgen(x, desc64)
}
-generic expgen = {f : @f, d : fltdesc(@f, @u, @i) :: numeric,floating,std.equatable @f, numeric,integral @u, numeric,integral @i, roundable @f -> @i
- var b = d.tobits(f)
+generic expgen = {x : @f, d : fltdesc(@f, @u, @i) :: numeric,floating,std.equatable @f, numeric,integral @u, numeric,integral @i, roundable @f -> @i
+ var b = d.tobits(x)
var n, e, s
- (n, e, s) = d.explode(f)
+ (n, e, s) = d.explode(x)
/*
Detect if exp(f) would round to outside representability.
@@ -226,7 +225,7 @@
/* Argument reduction to [ -ln(2)/64, ln(2)/64 ] */
var inv_L = d.frombits(d.inv_L)
- var N = rn(f * inv_L)
+ var N = rn(x * inv_L)
var N2 = N % (32 : @i)
if N2 < 0
N2 += (32 : @i)
@@ -242,9 +241,9 @@
(very well) f reduced into [ -ln(2)/64, ln(2)/64 ]
*/
if std.abs(N) >= (1 << d.nabs)
- R1 = (f - (N1 : @f) * d.frombits(d.L1)) - ((N2 : @f) * d.frombits(d.L1))
+ R1 = (x - (N1 : @f) * d.frombits(d.L1)) - ((N2 : @f) * d.frombits(d.L1))
else
- R1 = f - (N : @f) * d.frombits(d.L1)
+ R1 = x - (N : @f) * d.frombits(d.L1)
;;
R2 = -1.0 * (N : @f) * d.frombits(d.L2)
@@ -275,33 +274,33 @@
-> exp
}
-const expm132 = {f : flt32
- -> expm1gen(f, desc32)
+const expm132 = {x : flt32
+ -> expm1gen(x, desc32)
}
-const expm164 = {f : flt64
- -> expm1gen(f, desc64)
+const expm164 = {x : flt64
+ -> expm1gen(x, desc64)
}
-generic expm1gen = {f : @f, d : fltdesc(@f, @u, @i) :: numeric,floating,std.equatable @f, numeric,integral @u, numeric,integral @i, roundable @f -> @i
- var b = d.tobits(f)
+generic expm1gen = {x : @f, d : fltdesc(@f, @u, @i) :: numeric,floating,std.equatable @f, numeric,integral @u, numeric,integral @i, roundable @f -> @i
+ var b = d.tobits(x)
var n, e, s
- (n, e, s) = d.explode(f)
+ (n, e, s) = d.explode(x)
/* Special cases: +/- 0, inf, NaN, tiny, and huge */
if (b & ~d.sgnmask == 0)
- -> f
+ -> x
elif n && (b & ~d.sgnmask == d.inf)
-> (-1.0 : @f)
elif (b & ~d.sgnmask == d.inf)
- -> f
- elif std.isnan(f)
+ -> x
+ elif std.isnan(x)
-> d.frombits(d.nan)
elif (b & ~d.sgnmask) <= d.thresh_tiny
var two_to_large = d.assem(false, 100, 0)
var two_to_small = d.assem(false, -100, 0)
- var abs_f = d.assem(false, e, s)
- -> (two_to_large * f + abs_f) * two_to_small
+ var abs_x = d.assem(false, e, s)
+ -> (two_to_large * x + abs_x) * two_to_small
elif !n && b >= d.thresh_1_max /* exp(x) = oo <=> expm1(x) = oo, as it turns out */
-> d.frombits(d.inf)
elif n && b >= d.thresh_huge_neg
@@ -312,11 +311,11 @@
/* Procedure 2 */
/* compute x^2 / 2 with extra precision */
- var u = round(f, d)
- var v = f - u
+ var u = round(x, d)
+ var v = x - u
var y = u * u * (0.5 : @f)
- var z = v * (f + u) * (0.5 : @f)
- var q = f * f * f * d.horner(f, d.Bi)
+ var z = v * (x + u) * (0.5 : @f)
+ var q = x * x * x * d.horner(x, d.Bi)
var yn, ye, ys
(yn, ye, ys) = d.explode(y)
@@ -323,7 +322,7 @@
if (ye >= -7)
-> (u + y) + (q + (v + z))
else
- -> f + (y + (q + z))
+ -> x + (y + (q + z))
;;
;;
@@ -330,7 +329,7 @@
/* Procedure 1 */
var inv_L = d.frombits(d.inv_L)
- var N = rn(f * inv_L)
+ var N = rn(x * inv_L)
var N2 = N % (32 : @i)
if N2 < 0
N2 += (32 : @i)
@@ -344,9 +343,9 @@
reduced into [ -ln(2)/64, ln(2)/64 ]
*/
if std.abs(N) >= (1 << d.nabs)
- R1 = (f - (N1 : @f) * d.frombits(d.L1)) - ((N2 : @f) * d.frombits(d.L1))
+ R1 = (x - (N1 : @f) * d.frombits(d.L1)) - ((N2 : @f) * d.frombits(d.L1))
else
- R1 = f - (N : @f) * d.frombits(d.L1)
+ R1 = x - (N : @f) * d.frombits(d.L1)
;;
R2 = -1.0 * (N : @f) * d.frombits(d.L2)
--- a/lib/math/fpmath.myr
+++ b/lib/math/fpmath.myr
@@ -4,8 +4,8 @@
trait fpmath @f =
/* exp-impl */
- exp : (f : @f -> @f)
- expm1 : (f : @f -> @f)
+ exp : (x : @f -> @f)
+ expm1 : (x : @f -> @f)
/* fma-impl */
fma : (x : @f, y : @f, z : @f -> @f)
@@ -15,10 +15,10 @@
horner_polyu : (x : @f, a : @u[:] -> @f)
/* scale2-impl */
- scale2 : (f : @f, m : @i -> @f)
+ scale2 : (x : @f, m : @i -> @f)
/* sqrt-impl */
- sqrt : (f : @f -> @f)
+ sqrt : (x : @f -> @f)
/* sum-impl */
kahan_sum : (a : @f[:] -> @f)
@@ -25,14 +25,14 @@
priest_sum : (a : @f[:] -> @f)
/* trunc-impl */
- trunc : (f : @f -> @f)
- ceil : (f : @f -> @f)
- floor : (f : @f -> @f)
+ trunc : (x : @f -> @f)
+ ceil : (x : @f -> @f)
+ floor : (x : @f -> @f)
;;
trait roundable @f -> @i =
/* round-impl */
- rn : (f : @f -> @i)
+ rn : (x : @f -> @i)
;;
impl std.equatable flt32
@@ -60,32 +60,35 @@
;;
impl roundable flt32 -> int32 =
- rn = {f : flt32; -> rn32(f) }
+ rn = {x : flt32; -> rn32(x) }
;;
impl roundable flt64 -> int64 =
- rn = {f : flt64; -> rn64(f) }
+ rn = {x : flt64; -> rn64(x) }
;;
impl fpmath flt32 =
fma = {x, y, z; -> fma32(x, y, z)}
- exp = {f; -> exp32(f)}
- expm1 = {f; -> expm132(f)}
+ exp = {x; -> exp32(x)}
+ expm1 = {x; -> expm132(x)}
- horner_poly = {f, a; -> horner_poly32(f, a)}
- horner_polyu = {f, a; -> horner_polyu32(f, a)}
+ log = {x; -> log32(x)}
+ log1p = {x; -> log1p32(x)}
- scale2 = {f, m; -> scale232(f, m)}
+ horner_poly = {x, a; -> horner_poly32(x, a)}
+ horner_polyu = {x, a; -> horner_polyu32(x, a)}
- sqrt = {f; -> sqrt32(f)}
+ scale2 = {x, m; -> scale232(x, m)}
+ sqrt = {x; -> sqrt32(x)}
+
kahan_sum = {l; -> kahan_sum32(l) }
priest_sum = {l; -> priest_sum32(l) }
- trunc = {f; -> trunc32(f)}
- floor = {f; -> floor32(f)}
- ceil = {f; -> ceil32(f)}
+ trunc = {x; -> trunc32(x)}
+ floor = {x; -> floor32(x)}
+ ceil = {x; -> ceil32(x)}
;;
@@ -92,27 +95,33 @@
impl fpmath flt64 =
fma = {x, y, z; -> fma64(x, y, z)}
- exp = {f; -> exp64(f)}
- expm1 = {f; -> expm164(f)}
+ exp = {x; -> exp64(x)}
+ expm1 = {x; -> expm164(x)}
- horner_poly = {f, a; -> horner_poly64(f, a)}
- horner_polyu = {f, a; -> horner_polyu64(f, a)}
+ log = {x; -> log64(x)}
+ log1p = {x; -> log1p64(x)}
- scale2 = {f, m; -> scale264(f, m)}
+ horner_poly = {x, a; -> horner_poly64(x, a)}
+ horner_polyu = {x, a; -> horner_polyu64(x, a)}
- sqrt = {f; -> sqrt64(f)}
+ scale2 = {x, m; -> scale264(x, m)}
+ sqrt = {x; -> sqrt64(x)}
+
kahan_sum = {l; -> kahan_sum64(l) }
priest_sum = {l; -> priest_sum64(l) }
- trunc = {f; -> trunc64(f)}
- floor = {f; -> floor64(f)}
- ceil = {f; -> ceil64(f)}
+ trunc = {x; -> trunc64(x)}
+ floor = {x; -> floor64(x)}
+ ceil = {x; -> ceil64(x)}
;;
-extern const rn32 : (f : flt32 -> int32)
-extern const rn64 : (f : flt64 -> int64)
+extern const rn32 : (x : flt32 -> int32)
+extern const rn64 : (x : flt64 -> int64)
+extern const fma32 : (x : flt32, y : flt32, z : flt32 -> flt32)
+extern const fma64 : (x : flt64, y : flt64, z : flt64 -> flt64)
+
extern const exp32 : (x : flt32 -> flt32)
extern const exp64 : (x : flt64 -> flt64)
@@ -119,17 +128,17 @@
extern const expm132 : (x : flt32 -> flt32)
extern const expm164 : (x : flt64 -> flt64)
-extern const fma32 : (x : flt32, y : flt32, z : flt32 -> flt32)
-extern const fma64 : (x : flt64, y : flt64, z : flt64 -> flt64)
+extern const log32 : (x : flt32 -> flt32)
+extern const log64 : (x : flt64 -> flt64)
-extern const horner_poly32 : (f : flt32, a : flt32[:] -> flt32)
-extern const horner_poly64 : (f : flt64, a : flt64[:] -> flt64)
+extern const horner_poly32 : (x : flt32, a : flt32[:] -> flt32)
+extern const horner_poly64 : (x : flt64, a : flt64[:] -> flt64)
-extern const horner_polyu32 : (f : flt32, a : uint32[:] -> flt32)
-extern const horner_polyu64 : (f : flt64, a : uint64[:] -> flt64)
+extern const horner_polyu32 : (x : flt32, a : uint32[:] -> flt32)
+extern const horner_polyu64 : (x : flt64, a : uint64[:] -> flt64)
-extern const scale232 : (f : flt32, m : int32 -> flt32)
-extern const scale264 : (f : flt64, m : int64 -> flt64)
+extern const scale232 : (x : flt32, m : int32 -> flt32)
+extern const scale264 : (x : flt64, m : int64 -> flt64)
extern const sqrt32 : (x : flt32 -> flt32)
extern const sqrt64 : (x : flt64 -> flt64)
@@ -140,11 +149,11 @@
extern const priest_sum32 : (l : flt32[:] -> flt32)
extern const priest_sum64 : (l : flt64[:] -> flt64)
-extern const trunc32 : (f : flt32 -> flt32)
-extern const trunc64 : (f : flt64 -> flt64)
+extern const trunc32 : (x : flt32 -> flt32)
+extern const trunc64 : (x : flt64 -> flt64)
-extern const floor32 : (f : flt32 -> flt32)
-extern const floor64 : (f : flt64 -> flt64)
+extern const floor32 : (x : flt32 -> flt32)
+extern const floor64 : (x : flt64 -> flt64)
-extern const ceil32 : (f : flt32 -> flt32)
-extern const ceil64 : (f : flt64 -> flt64)
+extern const ceil32 : (x : flt32 -> flt32)
+extern const ceil64 : (x : flt64 -> flt64)
--- a/lib/math/poly-impl.myr
+++ b/lib/math/poly-impl.myr
@@ -2,44 +2,44 @@
/* See [Mul16], section 5.1 */
pkg math =
- pkglocal const horner_poly32 : (f : flt32, a : flt32[:] -> flt32)
- pkglocal const horner_poly64 : (f : flt64, a : flt64[:] -> flt64)
+ pkglocal const horner_poly32 : (x : flt32, a : flt32[:] -> flt32)
+ pkglocal const horner_poly64 : (x : flt64, a : flt64[:] -> flt64)
- pkglocal const horner_polyu32 : (f : flt32, a : uint32[:] -> flt32)
- pkglocal const horner_polyu64 : (f : flt64, a : uint64[:] -> flt64)
+ pkglocal const horner_polyu32 : (x : flt32, a : uint32[:] -> flt32)
+ pkglocal const horner_polyu64 : (x : flt64, a : uint64[:] -> flt64)
;;
extern const fma32 : (x : flt32, y : flt32, z : flt32 -> flt32)
extern const fma64 : (x : flt64, y : flt64, z : flt64 -> flt64)
-const horner_poly32 = {f : flt32, a : flt32[:]
+const horner_poly32 = {x : flt32, a : flt32[:]
var r : flt32 = 0.0
for var j = a.len - 1; j >= 0; j--
- r = fma32(r, f, a[j])
+ r = fma32(r, x, a[j])
;;
-> r
}
-const horner_poly64 = {f : flt64, a : flt64[:]
+const horner_poly64 = {x : flt64, a : flt64[:]
var r : flt64 = 0.0
for var j = a.len - 1; j >= 0; j--
- r = fma64(r, f, a[j])
+ r = fma64(r, x, a[j])
;;
-> r
}
-const horner_polyu32 = {f : flt32, a : uint32[:]
+const horner_polyu32 = {x : flt32, a : uint32[:]
var r : flt32 = 0.0
for var j = a.len - 1; j >= 0; j--
- r = fma32(r, f, std.flt32frombits(a[j]))
+ r = fma32(r, x, std.flt32frombits(a[j]))
;;
-> r
}
-const horner_polyu64 = {f : flt64, a : uint64[:]
+const horner_polyu64 = {x : flt64, a : uint64[:]
var r : flt64 = 0.0
for var j = a.len - 1; j >= 0; j--
- r = fma64(r, f, std.flt64frombits(a[j]))
+ r = fma64(r, x, std.flt64frombits(a[j]))
;;
-> r
}
--- a/lib/math/round-impl.myr
+++ b/lib/math/round-impl.myr
@@ -3,14 +3,14 @@
use "util"
pkg math =
- const rn64 : (f : flt64 -> int64)
- const rn32 : (f : flt32 -> int32)
+ const rn64 : (x : flt64 -> int64)
+ const rn32 : (x : flt32 -> int32)
;;
-const rn64 = {f : flt64
+const rn64 = {x : flt64
var n : bool, e : int64, s : uint64
- (n, e, s) = std.flt64explode(f)
+ (n, e, s) = std.flt64explode(x)
if e >= 63
-> -9223372036854775808
@@ -38,10 +38,10 @@
;;
}
-const rn32 = {f : flt32
+const rn32 = {x : flt32
var n : bool, e : int32, s : uint32
- (n, e, s) = std.flt32explode(f)
+ (n, e, s) = std.flt32explode(x)
if e >= 31
-> -2147483648
--- a/lib/math/scale2-impl.myr
+++ b/lib/math/scale2-impl.myr
@@ -9,20 +9,20 @@
approach works quite well.
*/
pkg math =
- const scale232 : (f : flt32, m : int32 -> flt32)
- const scale264 : (f : flt64, m : int64 -> flt64)
+ const scale232 : (x : flt32, m : int32 -> flt32)
+ const scale264 : (x : flt64, m : int64 -> flt64)
;;
-const scale232 = {f : flt32, m : int32
+const scale232 = {x : flt32, m : int32
var n, e, s
- (n, e, s) = std.flt32explode(f)
+ (n, e, s) = std.flt32explode(x)
(n, e, s) = scale2gen(n, e, s, -126, 127, 24, m)
-> std.flt32assem(n, e, s)
}
-const scale264 = {f : flt64, m : int64
+const scale264 = {x : flt64, m : int64
var n, e, s
- (n, e, s) = std.flt64explode(f)
+ (n, e, s) = std.flt64explode(x)
(n, e, s) = scale2gen(n, e, s, -1022, 1023, 53, m)
-> std.flt64assem(n, e, s)
}
--- a/lib/math/sqrt-impl.myr
+++ b/lib/math/sqrt-impl.myr
@@ -4,8 +4,8 @@
/* See [Mul+10], sections 5.4 and 8.7 */
pkg math =
- pkglocal const sqrt32 : (f : flt32 -> flt32)
- pkglocal const sqrt64 : (f : flt64 -> flt64)
+ pkglocal const sqrt32 : (x : flt32 -> flt32)
+ pkglocal const sqrt64 : (x : flt64 -> flt64)
;;
extern const fma32 : (x : flt32, y : flt32, z : flt32 -> flt32)
@@ -59,54 +59,56 @@
(0x4010000000000000, 0x3fe0a5989f2dc59a), /* [3.4, 4.0) -> 0.520214377304159869552790951275 */
][:]
-const sqrt32 = {f : flt32
- const d : fltdesc(flt32, uint32, int32) = [
- .explode = std.flt32explode,
- .assem = std.flt32assem,
- .fma = fma32,
- .tobits = std.flt32bits,
- .frombits = std.flt32frombits,
- .nan = 0x7fc00000,
- .emin = -127,
- .emax = 128,
- .normmask = 1 << 23,
- .sgnmask = 1 << 31,
- .ab = ab32,
- .iterlim = 3,
- ]
- -> sqrtgen(f, d)
+const desc32 : fltdesc(flt32, uint32, int32) = [
+ .explode = std.flt32explode,
+ .assem = std.flt32assem,
+ .fma = fma32,
+ .tobits = std.flt32bits,
+ .frombits = std.flt32frombits,
+ .nan = 0x7fc00000,
+ .emin = -127,
+ .emax = 128,
+ .normmask = 1 << 23,
+ .sgnmask = 1 << 31,
+ .ab = ab32,
+ .iterlim = 3,
+]
+
+const desc64 : fltdesc(flt64, uint64, int64) = [
+ .explode = std.flt64explode,
+ .assem = std.flt64assem,
+ .fma = fma64,
+ .tobits = std.flt64bits,
+ .frombits = std.flt64frombits,
+ .nan = 0x7ff8000000000000,
+ .emin = -1023,
+ .emax = 1024,
+ .normmask = 1 << 52,
+ .sgnmask = 1 << 63,
+ .ab = ab64,
+ .iterlim = 4,
+]
+
+const sqrt32 = {x : flt32
+ -> sqrtgen(x, desc32)
}
-const sqrt64 = {f : flt64
- const d : fltdesc(flt64, uint64, int64) = [
- .explode = std.flt64explode,
- .assem = std.flt64assem,
- .fma = fma64,
- .tobits = std.flt64bits,
- .frombits = std.flt64frombits,
- .nan = 0x7ff8000000000000,
- .emin = -1023,
- .emax = 1024,
- .normmask = 1 << 52,
- .sgnmask = 1 << 63,
- .ab = ab64,
- .iterlim = 4,
- ]
- -> sqrtgen(f, d)
+const sqrt64 = {x : flt64
+ -> sqrtgen(x, desc64)
}
-generic sqrtgen = {f : @f, d : fltdesc(@f, @u, @i) :: numeric,floating,std.equatable @f, numeric,integral @u, numeric,integral @i
+generic sqrtgen = {x : @f, d : fltdesc(@f, @u, @i) :: numeric,floating,std.equatable @f, numeric,integral @u, numeric,integral @i
var n : bool, e : @i, s : @u, e2 : @i
- (n, e, s) = d.explode(f)
+ (n, e, s) = d.explode(x)
/* Special cases: +/- 0.0, negative, NaN, and +inf */
if e == d.emin && s == 0
- -> f
- elif n || std.isnan(f)
+ -> x
+ elif n || std.isnan(x)
/* Make sure to return a quiet NaN */
-> d.frombits(d.nan)
elif e == d.emax
- -> f
+ -> x
;;
/*
--- a/lib/math/trunc-impl.myr
+++ b/lib/math/trunc-impl.myr
@@ -1,12 +1,12 @@
use std
pkg math =
- pkglocal const trunc32 : (f : flt32 -> flt32)
- pkglocal const floor32 : (f : flt32 -> flt32)
- pkglocal const ceil32 : (f : flt32 -> flt32)
- pkglocal const trunc64 : (f : flt64 -> flt64)
- pkglocal const floor64 : (f : flt64 -> flt64)
- pkglocal const ceil64 : (f : flt64 -> flt64)
+ pkglocal const trunc32 : (x : flt32 -> flt32)
+ pkglocal const floor32 : (x : flt32 -> flt32)
+ pkglocal const ceil32 : (x : flt32 -> flt32)
+ pkglocal const trunc64 : (x : flt64 -> flt64)
+ pkglocal const floor64 : (x : flt64 -> flt64)
+ pkglocal const ceil64 : (x : flt64 -> flt64)
;;
const Flt32NegMask : uint32 = (1 << 31)
@@ -15,13 +15,13 @@
const Flt64NegMask : uint64 = (1 << 63)
const Flt64SigMask : uint64 = (1 << 52) - 1
-pkglocal const floor32 = {f : flt32
+pkglocal const floor32 = {x : flt32
var n, e, s
- (n, e, s) = std.flt32explode(f)
+ (n, e, s) = std.flt32explode(x)
/* Many special cases */
- if e >= 23 || f == -0.0
- -> f
+ if e >= 23 || x == -0.0
+ -> x
elif e < 0
if n
-> -1.0
@@ -46,25 +46,25 @@
-> std.flt32assem(n, e, s & ~m)
}
-pkglocal const trunc32 = {f : flt32
- if std.flt32bits(f) & Flt32NegMask != 0
- -> -floor32(-f)
+pkglocal const trunc32 = {x : flt32
+ if std.flt32bits(x) & Flt32NegMask != 0
+ -> -floor32(-x)
else
- -> floor32(f)
+ -> floor32(x)
;;
}
-pkglocal const ceil32 = {f : flt32
- -> -floor32(-f)
+pkglocal const ceil32 = {x : flt32
+ -> -floor32(-x)
}
-pkglocal const floor64 = {f : flt64
+pkglocal const floor64 = {x : flt64
var n, e, s
- (n, e, s) = std.flt64explode(f)
+ (n, e, s) = std.flt64explode(x)
/* Many special cases */
- if e >= 52 || f == -0.0
- -> f
+ if e >= 52 || x == -0.0
+ -> x
elif e < 0
if n
-> -1.0
@@ -76,10 +76,10 @@
if n
var fractional_mask = Flt64SigMask >> (e : uint64)
if s & fractional_mask == 0
- -> f
+ -> x
else
/* Turns out the packing of exp and sig is useful */
- var u : uint64 = std.flt64bits(f) & ~fractional_mask
+ var u : uint64 = std.flt64bits(x) & ~fractional_mask
u += ((1 << 52) >> (e : uint64))
-> std.flt64frombits(u)
;;
@@ -89,15 +89,15 @@
-> std.flt64assem(n, e, s & ~m)
}
-pkglocal const trunc64 = {f : flt64
- if std.flt64bits(f) & Flt64NegMask != 0
- -> -floor64(-f)
+pkglocal const trunc64 = {x : flt64
+ if std.flt64bits(x) & Flt64NegMask != 0
+ -> -floor64(-x)
else
- -> floor64(f)
+ -> floor64(x)
;;
}
-pkglocal const ceil64 = {f : flt64
- -> -floor64(-f)
+pkglocal const ceil64 = {x : flt64
+ -> -floor64(-x)
}