ref: 0f469133aed044569f4d6ae9efc1d961124c05cd
parent: 6235cb639285f9ff5a7fc483a1950a8cd42f9aa9
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Sep 19 20:55:40 EDT 2015
Catch a few more edge cases.
--- a/lib/std/fltfmt.myr
+++ b/lib/std/fltfmt.myr
@@ -19,17 +19,11 @@
const Dblbias = 1023
const Fltbias = 127
-const Dblminmant = 1 << 52 /* the minimum mantissa for a normal float. */
const flt64bfmt = {sb, val, mode, precision
var isneg, exp, mant
(isneg, mant, exp) = flt64explode(val)
- /* adjust for denormals */
- while mant < Dblminmant
- mant <<= 1
- exp--
- ;;
dragon4(sb, isneg, mant, (exp - 52) castto(int64), Dblbias, mode, precision)
}
@@ -166,6 +160,9 @@
if k <= 0
sbputs(sb, "0.")
+ for var i = 0; i < -k; i++
+ sbputs(sb, "0")
+ ;;
;;
while true
k--
@@ -236,13 +233,7 @@
const format = {sb, d, k
const dig = "0123456789"
- var i
- if k < 0
- for i = 0; i < -k - 1; i++
- sbputs(sb, "0")
- ;;
- ;;
sbputb(sb, dig[d])
if k == 0
sbputs(sb, ".")
--- a/lib/std/test/bigint.myr
+++ b/lib/std/test/bigint.myr
@@ -42,7 +42,7 @@
b = try(std.bigparse("2234_5678_1234_6789_6666_7777_8888"))
match std.bigcmp(a, b)
| `std.Before: /* everything is as it should be */
- | `std.Equal: std.fatal("lies: {} == {}\n", a, b)
+ | `std.Equal: std.fatal("{} == {}\n", a, b)
| `std.After: std.fatal("lies: {} > {}\n", a, b)
;;
std.bigfree(a)
--- a/lib/std/test/fmt.myr
+++ b/lib/std/test/fmt.myr
@@ -39,6 +39,10 @@
check("123", "{}", 123)
check("7b", "{x}", 123)
check("0x7b", "0x{x}", 123)
+ check("0.3", "{}", 0.3)
+ check("666.91972", "{}", 666.91972)
+ check("1.0001", "{}", 1.0001)
+ check("0.000101323461002", "{}", 0.000101323461002)
}
const installed = {