Skip to content

Commit

Permalink
fix(std/strconv): fix parse_int()
Browse files Browse the repository at this point in the history
  • Loading branch information
StunxFS committed Nov 30, 2023
1 parent 46a6cb4 commit 1be8e2f
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/std/src/conv/parse_int.ri
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,12 @@ pub func parse_uint(s_: string, mut base: int32, mut bit_size: uint32) -> !uint

// Cutoff is the smallest number such that `cutoff * base > MAX_U64`.
// Use compile-time constants for common cases.
cutoff: uint := match base {
10 -> uint.MAX / 10 + 1,
16 -> uint.MAX / 16 + 1,
else -> uint.MAX / @as(uint, base) + @as(uint, 1)
};
cutoff: uint := (uint.MAX / @as(uint, base)) + 1;

max_val: uint := if bit_size == 64 {
uint.MAX
} else {
(@as(uint, 1) << @as(uint, bit_size)) - @as(uint, 1)
(@as(uint, 1) << @as(uint, bit_size)) - 1
};
mut underscores := false;
mut n: uint := 0;
Expand Down

0 comments on commit 1be8e2f

Please sign in to comment.