Skip to content

Commit 77a4e7b

Browse files
authored
Merge pull request #1958 from ziglang/parse-float
Add float parsing support to std
2 parents 5736a9c + 170ec50 commit 77a4e7b

File tree

15 files changed

+853
-10
lines changed

15 files changed

+853
-10
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ set(ZIG_STD_FILES
482482
"fmt/errol/index.zig"
483483
"fmt/errol/lookup.zig"
484484
"fmt/index.zig"
485+
"fmt/parse_float.zig"
485486
"hash/adler.zig"
486487
"hash/crc.zig"
487488
"hash/fnv.zig"
@@ -608,6 +609,7 @@ set(ZIG_STD_FILES
608609
"special/bootstrap_lib.zig"
609610
"special/build_runner.zig"
610611
"special/builtin.zig"
612+
"special/compiler_rt/addXf3.zig"
611613
"special/compiler_rt/aulldiv.zig"
612614
"special/compiler_rt/aullrem.zig"
613615
"special/compiler_rt/comparetf2.zig"

std/fmt/index.zig

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ pub fn parseUnsigned(comptime T: type, buf: []const u8, radix: u8) ParseUnsigned
831831
return x;
832832
}
833833

834-
test "parseUnsigned" {
834+
test "fmt.parseUnsigned" {
835835
testing.expect((try parseUnsigned(u16, "050124", 10)) == 50124);
836836
testing.expect((try parseUnsigned(u16, "65535", 10)) == 65535);
837837
testing.expectError(error.Overflow, parseUnsigned(u16, "65536", 10));
@@ -858,6 +858,12 @@ test "parseUnsigned" {
858858
testing.expectError(error.Overflow, parseUnsigned(u2, "4", 16));
859859
}
860860

861+
pub const parseFloat = @import("parse_float.zig").parseFloat;
862+
863+
test "fmt.parseFloat" {
864+
_ = @import("parse_float.zig");
865+
}
866+
861867
pub fn charToDigit(c: u8, radix: u8) (error{InvalidCharacter}!u8) {
862868
const value = switch (c) {
863869
'0'...'9' => c - '0',

0 commit comments

Comments
 (0)