diff --git a/lib/std/fmt/parse_float.zig b/lib/std/fmt/parse_float.zig index cb47faee8d31cb9128526349d90087ee9a80e36b..8b46986baef5692f1f8f58fc9adc1b54aa37c8d8 100644 --- a/lib/std/fmt/parse_float.zig +++ b/lib/std/fmt/parse_float.zig @@ -159,6 +159,9 @@ test "hex.special" { try testing.expect(math.isPositiveInf(try parseFloat(f32, "iNf"))); try testing.expect(math.isPositiveInf(try parseFloat(f32, "+Inf"))); try testing.expect(math.isNegativeInf(try parseFloat(f32, "-iNf"))); + + try testing.expect(math.isPositiveInf(try parseFloat(f32, "0x9999p9999"))); + try testing.expect(math.isNegativeInf(try parseFloat(f32, "-0x9999p9999"))); } test "hex.zero" { diff --git a/lib/std/fmt/parse_float/convert_hex.zig b/lib/std/fmt/parse_float/convert_hex.zig index d2063f1c00a073355a1b885589d92e16b58af3a1..2099eb16265ba92cd539c975c6fae77c36596f29 100644 --- a/lib/std/fmt/parse_float/convert_hex.zig +++ b/lib/std/fmt/parse_float/convert_hex.zig @@ -78,7 +78,7 @@ pub fn convertHex(comptime T: type, n_: Number(T)) T { // Infinity and range error if (n.exponent > max_exp) { - return math.inf(T); + return if (n.negative) -math.inf(T) else math.inf(T); } var bits = n.mantissa & ((1 << mantissa_bits) - 1);