summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-09-24 08:24:50 -0700
committerOri Bernstein <ori@eigenstate.org>2016-09-24 08:27:26 -0700
commit606bce2a5601d6a124da33d007e071ed9d43ff45 (patch)
tree3807d07495d841440e0c701fac807cc7f04eccb3
parent4eb7219a229bc8f9ac71a3a46f3fbfa875f32452 (diff)
downloadmc-606bce2a5601d6a124da33d007e071ed9d43ff45.tar.gz
Correctly format zero floats.
-rw-r--r--lib/std/fltfmt.myr7
-rw-r--r--lib/std/test/fmt.myr1
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/std/fltfmt.myr b/lib/std/fltfmt.myr
index bfd713b..f047cb6 100644
--- a/lib/std/fltfmt.myr
+++ b/lib/std/fltfmt.myr
@@ -41,7 +41,7 @@ e: exponent
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 @@ const dragon4 = {sb, isneg, f, e, p, mode, cutoff
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 @@ const dragon4 = {sb, isneg, f, e, p, mode, cutoff
| `After: format(sb, udig + 1, k)
;;
;;
- -> n
}
const lowdig = {u
diff --git a/lib/std/test/fmt.myr b/lib/std/test/fmt.myr
index de8a5a9..4d7f30e 100644
--- a/lib/std/test/fmt.myr
+++ b/lib/std/test/fmt.myr
@@ -62,6 +62,7 @@ const builtins = {
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)