zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 597648231b49500bbb8d15daa7f59cd52c1c3279 (tree)
parent d1243bf272b591a8deba5abedb56050edf3c3d6a
Author: frmdstryr <frmdstryr@protonmail.com>
Date:   Fri, 21 Feb 2020 22:26:13 -0500

Format decmial 0.0 with no precision as just 0

Diffstat:
Mlib/std/fmt.zig | 3+--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig @@ -757,8 +757,6 @@ pub fn formatFloatDecimal( } else { try output(context, ".0"); } - } else { - try output(context, "0"); } return; @@ -1399,6 +1397,7 @@ test "float.special" { test "float.decimal" { try testFmt("f64: 152314000000000000000000000000", "f64: {d}", .{@as(f64, 1.52314e+29)}); + try testFmt("f32: 0", "f32: {d}", .{@as(f32, 0.0)}); try testFmt("f32: 1.1", "f32: {d:.1}", .{@as(f32, 1.1234)}); try testFmt("f32: 1234.57", "f32: {d:.2}", .{@as(f32, 1234.567)}); // -11.1234 is converted to f64 -11.12339... internally (errol3() function takes f64).