Commit d1202b1f66
Changed files (2)
lib
std
json
lib/std/fmt/parse_float.zig
@@ -306,7 +306,7 @@ fn parseRepr(s: []const u8, n: *FloatRepr) !ParseResult {
State.Exponent => {
if (isDigit(c)) {
- if (exponent < std.math.maxInt(i32)) {
+ if (exponent < std.math.maxInt(i32) / 10) {
exponent *= 10;
exponent += @intCast(i32, c - '0');
}
@@ -417,6 +417,8 @@ test "fmt.parseFloat" {
expectEqual((try parseFloat(T, "inF")), std.math.inf(T));
expectEqual((try parseFloat(T, "-INF")), -std.math.inf(T));
+ expectEqual(try parseFloat(T, "0.4e0066999999999999999999999999999999999999999999999999999"), std.math.inf(T));
+
if (T != f16) {
expect(approxEq(T, try parseFloat(T, "1e-2"), 0.01, epsilon));
expect(approxEq(T, try parseFloat(T, "1234e-2"), 12.34, epsilon));
lib/std/json/test.zig
@@ -1751,11 +1751,9 @@ test "i_number_double_huge_neg_exp" {
}
test "i_number_huge_exp" {
- return error.SkipZigTest;
- // FIXME Integer overflow in parseFloat
- // any(
- // \\[0.4e00669999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999969999999006]
- // );
+ any(
+ \\[0.4e00669999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999969999999006]
+ );
}
test "i_number_neg_int_huge_exp" {