Fix #14901: parseFloat parsing 0x successfully

This commit is contained in:
Evin Yulo
2023-03-15 12:53:53 -04:00
committed by Veikka Tuominen
parent da0509750a
commit b3af5d076c
2 changed files with 3 additions and 0 deletions

View File

@@ -119,6 +119,7 @@ test "fmt.parseFloat hex.f16" {
}
test "fmt.parseFloat hex.f32" {
try testing.expectError(error.InvalidCharacter, parseFloat(f32, "0x"));
try testing.expectEqual(try parseFloat(f32, "0x1p0"), 1.0);
try testing.expectEqual(try parseFloat(f32, "-0x1p-1"), -0.5);
try testing.expectEqual(try parseFloat(f32, "0x10p+10"), 16384.0);