| ... | @@ -1200,8 +1200,6 @@ pub fn formatFloatDecimal( | ... | @@ -1200,8 +1200,6 @@ pub fn formatFloatDecimal( |
| 1200 | while (i < precision) : (i += 1) { | 1200 | while (i < precision) : (i += 1) { |
| 1201 | try writer.writeAll("0"); | 1201 | try writer.writeAll("0"); |
| 1202 | } | 1202 | } |
| 1203 | } else { | | |
| 1204 | try writer.writeAll(".0"); | | |
| 1205 | } | 1203 | } |
| 1206 | } | 1204 | } |
| 1207 | | 1205 | |
| ... | @@ -2198,6 +2196,7 @@ test "float.hexadecimal.precision" { | ... | @@ -2198,6 +2196,7 @@ test "float.hexadecimal.precision" { |
| 2198 | test "float.decimal" { | 2196 | test "float.decimal" { |
| 2199 | try expectFmt("f64: 152314000000000000000000000000", "f64: {d}", .{@as(f64, 1.52314e+29)}); | 2197 | try expectFmt("f64: 152314000000000000000000000000", "f64: {d}", .{@as(f64, 1.52314e+29)}); |
| 2200 | try expectFmt("f32: 0", "f32: {d}", .{@as(f32, 0.0)}); | 2198 | try expectFmt("f32: 0", "f32: {d}", .{@as(f32, 0.0)}); |
| | 2199 | try expectFmt("f32: 0", "f32: {d:.0}", .{@as(f32, 0.0)}); |
| 2201 | try expectFmt("f32: 1.1", "f32: {d:.1}", .{@as(f32, 1.1234)}); | 2200 | try expectFmt("f32: 1.1", "f32: {d:.1}", .{@as(f32, 1.1234)}); |
| 2202 | try expectFmt("f32: 1234.57", "f32: {d:.2}", .{@as(f32, 1234.567)}); | 2201 | try expectFmt("f32: 1234.57", "f32: {d:.2}", .{@as(f32, 1234.567)}); |
| 2203 | // -11.1234 is converted to f64 -11.12339... internally (errol3() function takes f64). | 2202 | // -11.1234 is converted to f64 -11.12339... internally (errol3() function takes f64). |