diff options
| author | Evin Yulo <yujiri@disroot.org> | 2023-03-15 12:53:53 -0400 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2023-03-16 19:36:06 +0200 |
| commit | b3af5d076c24744bdd100c25eabfea2a1a4688cf (patch) | |
| tree | 0281f22527f068adeba204c706affd26b676be2d /lib/std/fmt/parse_float/parse.zig | |
| parent | da0509750a332806cfddad24b88ae8900782185d (diff) | |
| download | zig-b3af5d076c24744bdd100c25eabfea2a1a4688cf.tar.gz zig-b3af5d076c24744bdd100c25eabfea2a1a4688cf.zip | |
Fix #14901: parseFloat parsing `0x` successfully
Diffstat (limited to 'lib/std/fmt/parse_float/parse.zig')
| -rw-r--r-- | lib/std/fmt/parse_float/parse.zig | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/std/fmt/parse_float/parse.zig b/lib/std/fmt/parse_float/parse.zig index 3b757c7c41..9f6e75b29a 100644 --- a/lib/std/fmt/parse_float/parse.zig +++ b/lib/std/fmt/parse_float/parse.zig @@ -107,6 +107,8 @@ fn parsePartialNumberBase(comptime T: type, stream: *FloatStream, negative: bool tryParseDigits(MantissaT, stream, &mantissa, info.base); var int_end = stream.offsetTrue(); var n_digits = @intCast(isize, stream.offsetTrue()); + // the base being 16 implies a 0x prefix, which shouldn't be included in the digit count + if (info.base == 16) n_digits -= 2; // handle dot with the following digits var exponent: i64 = 0; |
