diff options
Diffstat (limited to 'src/lexical')
-rw-r--r-- | src/lexical/algorithm.rs | 5 | ||||
-rw-r--r-- | src/lexical/digit.rs | 5 | ||||
-rw-r--r-- | src/lexical/errors.rs | 3 | ||||
-rw-r--r-- | src/lexical/math.rs | 4 | ||||
-rw-r--r-- | src/lexical/num.rs | 2 |
5 files changed, 12 insertions, 7 deletions
diff --git a/src/lexical/algorithm.rs b/src/lexical/algorithm.rs index a2cbf18..eaa5e7e 100644 --- a/src/lexical/algorithm.rs +++ b/src/lexical/algorithm.rs @@ -51,7 +51,10 @@ where // Compute the product of the power, if it overflows, // prematurely return early, otherwise, if we didn't overshoot, // we can get an exact value. - let value = mantissa.checked_mul(power)?; + let value = match mantissa.checked_mul(power) { + None => return None, + Some(value) => value, + }; if value >> mantissa_size != 0 { None } else { diff --git a/src/lexical/digit.rs b/src/lexical/digit.rs index 882aa9e..3d150a1 100644 --- a/src/lexical/digit.rs +++ b/src/lexical/digit.rs @@ -11,5 +11,8 @@ pub(crate) fn to_digit(c: u8) -> Option<u32> { // Add digit to mantissa. #[inline] pub(crate) fn add_digit(value: u64, digit: u32) -> Option<u64> { - value.checked_mul(10)?.checked_add(digit as u64) + match value.checked_mul(10) { + None => None, + Some(n) => n.checked_add(digit as u64), + } } diff --git a/src/lexical/errors.rs b/src/lexical/errors.rs index cad4bd3..f4f41cd 100644 --- a/src/lexical/errors.rs +++ b/src/lexical/errors.rs @@ -5,8 +5,7 @@ //! This estimates the error in a floating-point representation. //! //! This implementation is loosely based off the Golang implementation, -//! found here: -//! https://golang.org/src/strconv/atof.go +//! found here: <https://golang.org/src/strconv/atof.go> use super::float::*; use super::num::*; diff --git a/src/lexical/math.rs b/src/lexical/math.rs index 37cc1d2..d7122bf 100644 --- a/src/lexical/math.rs +++ b/src/lexical/math.rs @@ -336,7 +336,7 @@ mod small { pub fn imul(x: &mut Vec<Limb>, y: Limb) { // Multiply iteratively over all elements, adding the carry each time. let mut carry: Limb = 0; - for xi in x.iter_mut() { + for xi in &mut *x { carry = scalar::imul(xi, y, carry); } @@ -482,7 +482,7 @@ mod small { let rshift = bits - n; let lshift = n; let mut prev: Limb = 0; - for xi in x.iter_mut() { + for xi in &mut *x { let tmp = *xi; *xi <<= lshift; *xi |= prev >> rshift; diff --git a/src/lexical/num.rs b/src/lexical/num.rs index e47e003..af10afd 100644 --- a/src/lexical/num.rs +++ b/src/lexical/num.rs @@ -223,7 +223,7 @@ pub trait Float: Number { const NEGATIVE_INFINITY_BITS: Self::Unsigned; /// Size of the significand (mantissa) without hidden bit. const MANTISSA_SIZE: i32; - /// Bias of the exponet + /// Bias of the exponent const EXPONENT_BIAS: i32; /// Exponent portion of a denormal float. const DENORMAL_EXPONENT: i32; |