Skip to content

Commit d050829

Browse files
committed
fix many digits
1 parent 37da4f5 commit d050829

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

lib/std/fmt/parse_float.zig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ test "#11169" {
149149
}
150150

151151
test "many_digits hex" {
152-
// const a: f32 = try std.fmt.parseFloat(f32, "0xffffffffffffffff.0p0"); // This fails btw.
153-
// const b: f32 = @floatCast(try std.fmt.parseFloat(f128, "0xffffffffffffffff.0p0"));
154-
// try std.testing.expectEqual(a, b);
152+
const a: f32 = try parseFloat(f32, "0xffffffffffffffff.0p0");
153+
const b: f32 = @floatCast(try parseFloat(f128, "0xffffffffffffffff.0p0"));
154+
try std.testing.expectEqual(a, b);
155155
}
156156

157157
test "hex.special" {
@@ -160,6 +160,7 @@ test "hex.special" {
160160
try testing.expect(math.isPositiveInf(try parseFloat(f32, "+Inf")));
161161
try testing.expect(math.isNegativeInf(try parseFloat(f32, "-iNf")));
162162
}
163+
163164
test "hex.zero" {
164165
try testing.expectEqual(@as(f32, 0.0), try parseFloat(f32, "0x0"));
165166
try testing.expectEqual(@as(f32, 0.0), try parseFloat(f32, "-0x0"));

lib/std/fmt/parse_float/FloatInfo.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ pub fn from(comptime T: type) Self {
113113
.max_exponent_fast_path_disguised = 46,
114114
.max_mantissa_fast_path = 2 << std.math.floatMantissaBits(T),
115115
// Slow + Eisel-Lemire
116-
.mantissa_explicit_bits = std.math.floatMantissaBits(T) - 1,
116+
.mantissa_explicit_bits = std.math.floatFractionalBits(T),
117117
.infinite_power = 0x7fff,
118118
// Eisel-Lemire.
119119
// NOTE: Not yet tested (no f80 eisel-lemire implementation)

lib/std/fmt/parse_float/convert_hex.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub fn convertHex(comptime T: type, n_: Number(T)) T {
2929
const exp_bits = math.floatExponentBits(T);
3030
const exp_bias = min_exp - 1;
3131

32-
// mantissa now implicitly divided by 2^mantissa_bits
32+
// mantissa now implicitly divided by 2^fractional_bits
3333
n.exponent += fractional_bits;
3434

3535
// Shift mantissa and exponent to bring representation into float range.

0 commit comments

Comments
 (0)