summaryrefslogtreecommitdiff
path: root/lib/math/trunc-impl.myr
diff options
context:
space:
mode:
authorS. Gilles <sgilles@math.umd.edu>2018-05-10 10:42:25 -0400
committerS. Gilles <sgilles@math.umd.edu>2018-05-10 10:42:25 -0400
commit66a472dc689c3a7b2b8f077fdf01c0dc2fdc1f7d (patch)
treeed949586ac1c84b852324941b0e730064cc6b898 /lib/math/trunc-impl.myr
parent3853fa79b7d297f4bd3aaf318a147a95dd088bc9 (diff)
downloadmc-66a472dc689c3a7b2b8f077fdf01c0dc2fdc1f7d.tar.gz
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.
Diffstat (limited to 'lib/math/trunc-impl.myr')
-rw-r--r--lib/math/trunc-impl.myr56
1 files changed, 28 insertions, 28 deletions
diff --git a/lib/math/trunc-impl.myr b/lib/math/trunc-impl.myr
index 0ce41ca..e0f916a 100644
--- 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 Flt32SigMask : uint32 = (1 << 23) - 1
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 @@ pkglocal const floor32 = {f : flt32
-> 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 @@ pkglocal const floor64 = {f : flt64
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 @@ pkglocal const floor64 = {f : flt64
-> 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)
}