From c0de4b0b7f3511bc8b3f166f393181805a9c2569 Mon Sep 17 00:00:00 2001 From: Will Leinweber Date: Mon, 24 Apr 2017 17:37:46 -0700 Subject: [PATCH] FloatPrinter: remove -NaN test, fix formatting --- spec/std/float_printer_spec.cr | 2 +- src/float_printer.cr | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/spec/std/float_printer_spec.cr b/spec/std/float_printer_spec.cr index 87cb94f63c40..5e32d79f8264 100644 --- a/spec/std/float_printer_spec.cr +++ b/spec/std/float_printer_spec.cr @@ -27,7 +27,7 @@ describe "#print" do it { test_str "Infinity" } - it { test_str "NaN" } + it { test_pair Float64::NAN, "NaN" } it { test_str "0.01" } it { test_str "0.1" } diff --git a/src/float_printer.cr b/src/float_printer.cr index 604ee3da9ae9..c8408c18b867 100644 --- a/src/float_printer.cr +++ b/src/float_printer.cr @@ -59,11 +59,11 @@ module FloatPrinter # add integer part digits if decimal_exponent > 0 && !exp_mode # whole number but not big enough to be exp form - io.write_utf8 buffer.to_slice[i, length-i] + io.write_utf8 buffer.to_slice[i, length - i] i = length (point - length).times { io << '0' } elsif i < point - io.write_utf8 buffer.to_slice[i, point-i] + io.write_utf8 buffer.to_slice[i, point - i] i = point end @@ -75,10 +75,9 @@ module FloatPrinter end # add fractional part digits - io.write_utf8 buffer.to_slice[i, length-i] + io.write_utf8 buffer.to_slice[i, length - i] i = length - # print trailing 0 if whole number or exp notation of power of ten if (decimal_exponent >= 0 && !exp_mode) || (exp != point && length == 1) io << '0'