ref: 606bce2a5601d6a124da33d007e071ed9d43ff45
parent: 4eb7219a229bc8f9ac71a3a46f3fbfa875f32452
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Sep 24 04:24:50 EDT 2016
Correctly format zero floats.
--- a/lib/std/fltfmt.myr
+++ b/lib/std/fltfmt.myr
@@ -41,7 +41,7 @@
p: precision
f: mantissa
-flting value: x = f^(e - p)
+floating value: x = f^(e - p)
*/
const dragon4 = {sb, isneg, f, e, p, mode, cutoff
var r, s, t, u, v, y
@@ -49,16 +49,16 @@
var mm, mp /* margins above and below */
var roundup
var low, high
- var k, n
+ var k
var a, i
/* if we have zero for the mantissa, we can return early */
- n = 0
if isneg
sbputs(sb, "-")
;;
if f == 0
sbputs(sb, "0.0")
+ -> void
;;
/* initialize */
@@ -223,7 +223,6 @@
| `After: format(sb, udig + 1, k)
;;
;;
- -> n
}
const lowdig = {u
--- a/lib/std/test/fmt.myr
+++ b/lib/std/test/fmt.myr
@@ -62,6 +62,7 @@
check("123", "{}", 123)
check("7b", "{x}", 123)
check("0x7b", "0x{x}", 123)
+ check("0.0", "{}", 0.0)
check("0.3", "{}", 0.3)
check("666.91972", "{}", 666.91972)
check("1.0001", "{}", 1.0001)