summaryrefslogtreecommitdiff
path: root/lib/std/fltfmt.myr
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std/fltfmt.myr')
-rw-r--r--lib/std/fltfmt.myr10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/std/fltfmt.myr b/lib/std/fltfmt.myr
index b0c08c4..9988c06 100644
--- a/lib/std/fltfmt.myr
+++ b/lib/std/fltfmt.myr
@@ -25,13 +25,15 @@ const flt64bfmt = {sb, val, mode, precision
var isneg, exp, mant
(isneg, mant, exp) = flt64explode(val)
- dragon4(sb, isneg, mant, (exp - 52 : int64), Dblbias, mode, precision)
+ exp = max(exp, 1 - Dblbias)
+ dragon4(sb, isneg, mant, exp - 52, Dblbias, mode, precision)
}
const flt32bfmt = {sb, val, mode, precision
var isneg, exp, mant
(isneg, mant, exp) = flt32explode(val)
+ exp = (max((exp : int64), 1 - Fltbias) : int32)
dragon4(sb, isneg, (mant : uint64), (exp - 23 : int64), Fltbias, mode, precision)
}
@@ -64,9 +66,9 @@ const dragon4 = {sb, isneg, f, e, p, mode, cutoff
/* initialize */
roundup = false
u = mkbigint(0)
- r = bigshli(mkbigint(f), max(e - p, 0))
- s = bigshli(mkbigint(1), max(0, -(e - p)))
- mm = bigshli(mkbigint(1), max((e - p), 0))
+ r = bigshli(mkbigint(f), max(e, 0))
+ s = bigshli(mkbigint(1), max(0, -e))
+ mm = bigshli(mkbigint(1), max(e, 0))
mp = bigdup(mm)
/* fixup: unequal gaps */