We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ab7d959 commit 2cf9c5cCopy full SHA for 2cf9c5c
src/compute.rs
@@ -34,6 +34,9 @@ fn parse_float(bytes: &[u8]) -> i32 {
34
let sgn = 1 - 2 * neg as i32;
35
let res = bytes.iter().skip(neg).fold(0, |acc, &byte| {
36
let is_digit = byte.is_ascii_digit() as i32;
37
+ // one of the bytes is b'.' which would cause integer overflow
38
+ // if b'0' is subracted from it, and `is_digit` is 0 in that
39
+ // case.
40
let digit = (byte as i32).wrapping_sub(b'0' as i32);
41
acc * (10 * is_digit + (1 - is_digit)) + digit * is_digit
42
});
0 commit comments