ref: 6fb7d34b848c598e6398f960dc0a7e240e09a6f5
parent: 007b768f79b8a45846062086451484a32c1e30fd
author: S. Gilles <sgilles@math.umd.edu>
date: Mon Mar 12 02:34:25 EDT 2018
Reorder arguments/results of fltXY{explode/assem}
--- a/lib/std/fltbits.myr
+++ b/lib/std/fltbits.myr
@@ -9,10 +9,10 @@
generic isnan : (f : @a -> bool) ::floating @a
const flt64frombits : (bits : uint64 -> flt64)
const flt32frombits : (bits : uint32 -> flt32)
- const flt64explode : (flt : flt64 -> (bool, uint64, int64))
- const flt32explode : (flt : flt32 -> (bool, uint32, int32))
- const flt64assem : (sign : bool, mant : uint64, exp : int64 -> flt64)
- const flt32assem : (sign : bool, mant : uint32, exp : int32 -> flt32)
+ const flt64explode : (flt : flt64 -> (bool, int64, uint64))
+ const flt32explode : (flt : flt32 -> (bool, int32, uint32))
+ const flt64assem : (sign : bool, exp : int64, mant : uint64 -> flt64)
+ const flt32assem : (sign : bool, exp : int32, mant : uint32 -> flt32)
;;
const flt64bits = {flt; -> (&flt : uint64#)#}
@@ -38,7 +38,7 @@
/* adjust for exponent bias */
exp = (uexp : int64) - Dblbias
- -> (isneg, mant, exp)
+ -> (isneg, exp, mant)
}
const flt32explode = {flt
@@ -56,10 +56,10 @@
/* adjust for exponent bias */
exp = (uexp : int32) - Fltbias
- -> (isneg, mant, exp)
+ -> (isneg, exp, mant)
}
-const flt64assem = {sign, mant, exp
+const flt64assem = {sign, exp, mant
var s, m, e
s = (sign : uint64)
@@ -68,7 +68,7 @@
-> std.flt64frombits((s << 63) | (e << 52) | m)
}
-const flt32assem = {sign, mant, exp
+const flt32assem = {sign, exp, mant
var s, m, e
s = (sign : uint32)
--- a/lib/std/fltfmt.myr
+++ b/lib/std/fltfmt.myr
@@ -24,7 +24,7 @@
const flt64bfmt = {sb, val, mode, precision
var isneg, exp, mant
- (isneg, mant, exp) = flt64explode(val)
+ (isneg, exp, mant) = flt64explode(val)
exp = max(exp, 1 - Dblbias)
dragon4(sb, isneg, mant, exp - 52, Dblbias, mode, precision)
}
@@ -32,7 +32,7 @@
const flt32bfmt = {sb, val, mode, precision
var isneg, exp, mant
- (isneg, mant, exp) = flt32explode(val)
+ (isneg, exp, mant) = flt32explode(val)
exp = (max((exp : int64), 1 - Fltbias) : int32)
dragon4(sb, isneg, (mant : uint64), (exp - 23 : int64), Fltbias, mode, precision)
}
--- a/lib/std/fltparse.myr
+++ b/lib/std/fltparse.myr
@@ -264,7 +264,7 @@
var sign, mant, exp
var za
- (sign, mant, exp) = std.flt64explode(z)
+ (sign, exp, mant) = std.flt64explode(z)
if std.abs((mant : int64) - (1l << 52) - 1) < (lim.nextinc : int64)
mant = 0
exp++
@@ -271,7 +271,7 @@
else
mant += lim.nextinc
;;
- za = std.flt64assem(sign, mant, exp)
+ za = std.flt64assem(sign, exp, mant)
-> za
}
--- a/lib/std/test/fltbits.myr
+++ b/lib/std/test/fltbits.myr
@@ -112,13 +112,13 @@
in order for flt32assem to work as expected
*/
for (n, e, s) : [
- (false, 0, -127),
- (true, 0, -127),
- (false, 0x399, -127),
- (true, 0x23, -127),
- (false, (1 << 23) | 0x23, 45),
- (true, (1 << 23) | 0x3a2, -12),
- (true, (1 << 23) | 0x3a1, -126),
+ (false, -127, 0),
+ (true, -127, 0),
+ (false, -127, 0x399),
+ (true, -127, 0x23),
+ (false, 45, (1 << 23) | 0x23),
+ (true, -12, (1 << 23) | 0x3a2),
+ (true, -126, (1 << 23) | 0x3a1),
][:]
var m, f, t
(m, f, t) = std.flt32explode(std.flt32assem(n, e, s))
@@ -141,15 +141,15 @@
in order for flt32assem to work as expected
*/
for (n, e, s) : [
- (false, 0, -1023),
- (true, 0, -1023),
- (false, 0x399, -1023),
- (true, 0x23, -1023),
- (false, (1 << 52) | 0xa33bc, 45),
- (true, (1 << 52) | 0x3, -12),
- (true, (1 << 52) | 0x11aabbcc, -200),
- (true, (1 << 52) | 0x3a1, 543),
- (true, (1 << 52) | 0x99aa228, 1001),
+ (false, -1023, 0),
+ (true, -1023, 0),
+ (false, -1023, 0x399),
+ (true, -1023, 0x23),
+ (false, 45, (1 << 52) | 0xa33bc),
+ (true, -12, (1 << 52) | 0x3),
+ (true, -200, (1 << 52) | 0x11aabbcc),
+ (true, 543, (1 << 52) | 0x3a1),
+ (true, 1001, (1 << 52) | 0x99aa228),
][:]
var m, f, t
(m, f, t) = std.flt64explode(std.flt64assem(n, e, s))