Skip to content

Commit c103c12

Browse files
committed
fixed from MR review
1 parent d050829 commit c103c12

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

lib/std/fmt/format_float.zig

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,15 +1521,13 @@ fn check(comptime T: type, value: T, comptime expected: []const u8) !void {
15211521
const s = try formatFloat(&buf, value, .{});
15221522
try std.testing.expectEqualStrings(expected, s);
15231523

1524-
if (@bitSizeOf(T) != 80) {
1525-
const o = try std.fmt.parseFloat(T, s);
1526-
const o_bits: I = @bitCast(o);
1524+
const o = try std.fmt.parseFloat(T, s);
1525+
const o_bits: I = @bitCast(o);
15271526

1528-
if (std.math.isNan(value)) {
1529-
try std.testing.expect(std.math.isNan(o));
1530-
} else {
1531-
try std.testing.expectEqual(value_bits, o_bits);
1532-
}
1527+
if (std.math.isNan(value)) {
1528+
try std.testing.expect(std.math.isNan(o));
1529+
} else {
1530+
try std.testing.expectEqual(value_bits, o_bits);
15331531
}
15341532
}
15351533

lib/std/fmt/parse_float/FloatInfo.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub fn from(comptime T: type) Self {
6060
.max_exponent_fast_path_disguised = 7,
6161
.max_mantissa_fast_path = 2 << std.math.floatMantissaBits(T),
6262
// Slow + Eisel-Lemire
63-
.mantissa_explicit_bits = std.math.floatMantissaBits(T),
63+
.mantissa_explicit_bits = std.math.floatFractionalBits(T),
6464
.infinite_power = 0x1f,
6565
// Eisel-Lemire
6666
.smallest_power_of_ten = -26, // TODO: refine, fails one test
@@ -81,7 +81,7 @@ pub fn from(comptime T: type) Self {
8181
.max_exponent_fast_path_disguised = 17,
8282
.max_mantissa_fast_path = 2 << std.math.floatMantissaBits(T),
8383
// Slow + Eisel-Lemire
84-
.mantissa_explicit_bits = std.math.floatMantissaBits(T),
84+
.mantissa_explicit_bits = std.math.floatFractionalBits(T),
8585
.infinite_power = 0xff,
8686
// Eisel-Lemire
8787
.smallest_power_of_ten = -65,
@@ -133,7 +133,7 @@ pub fn from(comptime T: type) Self {
133133
.max_exponent_fast_path_disguised = 82,
134134
.max_mantissa_fast_path = 2 << std.math.floatMantissaBits(T),
135135
// Slow + Eisel-Lemire
136-
.mantissa_explicit_bits = std.math.floatMantissaBits(T),
136+
.mantissa_explicit_bits = std.math.floatFractionalBits(T),
137137
.infinite_power = 0x7fff,
138138
// Eisel-Lemire.
139139
// NOTE: Not yet tested (no f128 eisel-lemire implementation)

lib/std/fmt/parse_float/common.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ pub fn isEightDigits(v: u64) bool {
7777
}
7878

7979
pub fn isDigit(c: u8, comptime base: u8) bool {
80+
std.debug.assert(base == 10 or base == 16);
81+
8082
return if (base == 10)
8183
'0' <= c and c <= '9'
8284
else

0 commit comments

Comments
 (0)