diff options
| author | bors <bors@rust-lang.org> | 2018-12-08 03:50:16 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-12-08 03:50:16 +0000 |
| commit | 059e6a6f57f4e80d527a3cd8a8afe7f51f01af8e (patch) | |
| tree | 90e0d7a855be8202279b6bdde6cbdc95d834f07a /src/libcore/num | |
| parent | 0a7798079608b4ff014471ae64b6c8201aa59cdf (diff) | |
| parent | 003c5b796eae78c8c260bfddfc332a69926a6152 (diff) | |
| download | rust-059e6a6f57f4e80d527a3cd8a8afe7f51f01af8e.tar.gz rust-059e6a6f57f4e80d527a3cd8a8afe7f51f01af8e.zip | |
Auto merge of #56578 - alexreg:cosmetic-1, r=alexreg
Various minor/cosmetic improvements to code r? @Centril 😄
Diffstat (limited to 'src/libcore/num')
| -rw-r--r-- | src/libcore/num/bignum.rs | 2 | ||||
| -rw-r--r-- | src/libcore/num/dec2flt/algorithm.rs | 6 | ||||
| -rw-r--r-- | src/libcore/num/dec2flt/rawfp.rs | 2 | ||||
| -rw-r--r-- | src/libcore/num/flt2dec/mod.rs | 6 | ||||
| -rw-r--r-- | src/libcore/num/flt2dec/strategy/dragon.rs | 8 | ||||
| -rw-r--r-- | src/libcore/num/flt2dec/strategy/grisu.rs | 14 | ||||
| -rw-r--r-- | src/libcore/num/mod.rs | 8 | ||||
| -rw-r--r-- | src/libcore/num/wrapping.rs | 2 |
8 files changed, 24 insertions, 24 deletions
diff --git a/src/libcore/num/bignum.rs b/src/libcore/num/bignum.rs index 732a02e8c42..2bfb49c0682 100644 --- a/src/libcore/num/bignum.rs +++ b/src/libcore/num/bignum.rs @@ -183,7 +183,7 @@ macro_rules! define_bignum { let nonzero = &digits[..end]; if nonzero.is_empty() { - // There are no non-zero digits, i.e. the number is zero. + // There are no non-zero digits, i.e., the number is zero. return 0; } // This could be optimized with leading_zeros() and bit shifts, but that's diff --git a/src/libcore/num/dec2flt/algorithm.rs b/src/libcore/num/dec2flt/algorithm.rs index ccf3950c2ba..c3a983d0f0e 100644 --- a/src/libcore/num/dec2flt/algorithm.rs +++ b/src/libcore/num/dec2flt/algorithm.rs @@ -61,9 +61,9 @@ mod fpu_precision { /// /// The only field which is relevant for the following code is PC, Precision Control. This /// field determines the precision of the operations performed by the FPU. It can be set to: - /// - 0b00, single precision i.e. 32-bits - /// - 0b10, double precision i.e. 64-bits - /// - 0b11, double extended precision i.e. 80-bits (default state) + /// - 0b00, single precision i.e., 32-bits + /// - 0b10, double precision i.e., 64-bits + /// - 0b11, double extended precision i.e., 80-bits (default state) /// The 0b01 value is reserved and should not be used. pub struct FPUControlWord(u16); diff --git a/src/libcore/num/dec2flt/rawfp.rs b/src/libcore/num/dec2flt/rawfp.rs index 38f4e4687a9..18c30e29c79 100644 --- a/src/libcore/num/dec2flt/rawfp.rs +++ b/src/libcore/num/dec2flt/rawfp.rs @@ -349,7 +349,7 @@ pub fn prev_float<T: RawFloat>(x: T) -> T { } // Find the smallest floating point number strictly larger than the argument. -// This operation is saturating, i.e. next_float(inf) == inf. +// This operation is saturating, i.e., next_float(inf) == inf. // Unlike most code in this module, this function does handle zero, subnormals, and infinities. // However, like all other code here, it does not deal with NaN and negative numbers. pub fn next_float<T: RawFloat>(x: T) -> T { diff --git a/src/libcore/num/flt2dec/mod.rs b/src/libcore/num/flt2dec/mod.rs index d58015beecb..097240e58ae 100644 --- a/src/libcore/num/flt2dec/mod.rs +++ b/src/libcore/num/flt2dec/mod.rs @@ -23,7 +23,7 @@ representation `V = 0.d[0..n-1] * 10^k` such that: - `d[0]` is non-zero. - It's correctly rounded when parsed back: `v - minus < V < v + plus`. - Furthermore it is shortest such one, i.e. there is no representation + Furthermore it is shortest such one, i.e., there is no representation with less than `n` digits that is correctly rounded. - It's closest to the original value: `abs(V - v) <= 10^(k-n) / 2`. Note that @@ -398,7 +398,7 @@ fn determine_sign(sign: Sign, decoded: &FullDecoded, negative: bool) -> &'static /// given number of fractional digits. The result is stored to the supplied parts /// array while utilizing given byte buffer as a scratch. `upper` is currently /// unused but left for the future decision to change the case of non-finite values, -/// i.e. `inf` and `nan`. The first part to be rendered is always a `Part::Sign` +/// i.e., `inf` and `nan`. The first part to be rendered is always a `Part::Sign` /// (which can be an empty string if no sign is rendered). /// /// `format_shortest` should be the underlying digit-generation function. @@ -591,7 +591,7 @@ pub fn to_exact_exp_str<'a, T, F>(mut format_exact: F, v: T, /// given number of fractional digits. The result is stored to the supplied parts /// array while utilizing given byte buffer as a scratch. `upper` is currently /// unused but left for the future decision to change the case of non-finite values, -/// i.e. `inf` and `nan`. The first part to be rendered is always a `Part::Sign` +/// i.e., `inf` and `nan`. The first part to be rendered is always a `Part::Sign` /// (which can be an empty string if no sign is rendered). /// /// `format_exact` should be the underlying digit-generation function. diff --git a/src/libcore/num/flt2dec/strategy/dragon.rs b/src/libcore/num/flt2dec/strategy/dragon.rs index aa6a08cb205..cda0773afbd 100644 --- a/src/libcore/num/flt2dec/strategy/dragon.rs +++ b/src/libcore/num/flt2dec/strategy/dragon.rs @@ -81,11 +81,11 @@ pub fn format_shortest(d: &Decoded, buf: &mut [u8]) -> (/*#digits*/ usize, /*exp // - followed by `(mant + 2 * plus) * 2^exp` in the original type. // // obviously, `minus` and `plus` cannot be zero. (for infinities, we use out-of-range values.) - // also we assume that at least one digit is generated, i.e. `mant` cannot be zero too. + // also we assume that at least one digit is generated, i.e., `mant` cannot be zero too. // // this also means that any number between `low = (mant - minus) * 2^exp` and // `high = (mant + plus) * 2^exp` will map to this exact floating point number, - // with bounds included when the original mantissa was even (i.e. `!mant_was_odd`). + // with bounds included when the original mantissa was even (i.e., `!mant_was_odd`). assert!(d.mant > 0); assert!(d.minus > 0); @@ -172,7 +172,7 @@ pub fn format_shortest(d: &Decoded, buf: &mut [u8]) -> (/*#digits*/ usize, /*exp // - `high - v = plus / scale * 10^(k-n)` // // assume that `d[0..n-1]` is the shortest representation between `low` and `high`, - // i.e. `d[0..n-1]` satisfies both of the following but `d[0..n-2]` doesn't: + // i.e., `d[0..n-1]` satisfies both of the following but `d[0..n-2]` doesn't: // - `low < d[0..n-1] * 10^(k-n) < high` (bijectivity: digits round to `v`); and // - `abs(v / 10^(k-n) - d[0..n-1]) <= 1/2` (the last digit is correct). // @@ -304,7 +304,7 @@ pub fn format_exact(d: &Decoded, buf: &mut [u8], limit: i16) -> (/*#digits*/ usi // rounding up if we stop in the middle of digits // if the following digits are exactly 5000..., check the prior digit and try to - // round to even (i.e. avoid rounding up when the prior digit is even). + // round to even (i.e., avoid rounding up when the prior digit is even). let order = mant.cmp(scale.mul_small(5)); if order == Ordering::Greater || (order == Ordering::Equal && (len == 0 || buf[len-1] & 1 == 1)) { diff --git a/src/libcore/num/flt2dec/strategy/grisu.rs b/src/libcore/num/flt2dec/strategy/grisu.rs index effe073c381..3e76feca885 100644 --- a/src/libcore/num/flt2dec/strategy/grisu.rs +++ b/src/libcore/num/flt2dec/strategy/grisu.rs @@ -242,7 +242,7 @@ pub fn format_shortest_opt(d: &Decoded, // // find the digit length `kappa` between `(minus1, plus1)` as per Theorem 6.2. // Theorem 6.2 can be adopted to exclude `x` by requiring `y mod 10^k < y - x` instead. - // (e.g. `x` = 32000, `y` = 32777; `kappa` = 2 since `y mod 10^3 = 777 < y - x = 777`.) + // (e.g., `x` = 32000, `y` = 32777; `kappa` = 2 since `y mod 10^3 = 777 < y - x = 777`.) // the algorithm relies on the later verification phase to exclude `y`. let delta1 = plus1 - minus1; // let delta1int = (delta1 >> e) as usize; // only for explanation @@ -362,19 +362,19 @@ pub fn format_shortest_opt(d: &Decoded, // proceed, but we then have at least one valid representation known to be closest to // `v + 1 ulp` anyway. we will denote them as TC1 through TC3 for brevity. // - // TC1: `w(n) <= v + 1 ulp`, i.e. this is the last repr that can be the closest one. + // TC1: `w(n) <= v + 1 ulp`, i.e., this is the last repr that can be the closest one. // this is equivalent to `plus1 - w(n) = plus1w(n) >= plus1 - (v + 1 ulp) = plus1v_up`. // combined with TC2 (which checks if `w(n+1)` is valid), this prevents the possible // overflow on the calculation of `plus1w(n)`. // - // TC2: `w(n+1) < minus1`, i.e. the next repr definitely does not round to `v`. + // TC2: `w(n+1) < minus1`, i.e., the next repr definitely does not round to `v`. // this is equivalent to `plus1 - w(n) + 10^kappa = plus1w(n) + 10^kappa > // plus1 - minus1 = threshold`. the left hand side can overflow, but we know // `threshold > plus1v`, so if TC1 is false, `threshold - plus1w(n) > // threshold - (plus1v - 1 ulp) > 1 ulp` and we can safely test if // `threshold - plus1w(n) < 10^kappa` instead. // - // TC3: `abs(w(n) - (v + 1 ulp)) <= abs(w(n+1) - (v + 1 ulp))`, i.e. the next repr is + // TC3: `abs(w(n) - (v + 1 ulp)) <= abs(w(n+1) - (v + 1 ulp))`, i.e., the next repr is // no closer to `v + 1 ulp` than the current repr. given `z(n) = plus1v_up - plus1w(n)`, // this becomes `abs(z(n)) <= abs(z(n+1))`. again assuming that TC1 is false, we have // `z(n) > 0`. we have two cases to consider: @@ -384,7 +384,7 @@ pub fn format_shortest_opt(d: &Decoded, // - when `z(n+1) < 0`: // - TC3a: the precondition is `plus1v_up < plus1w(n) + 10^kappa`. assuming TC2 is // false, `threshold >= plus1w(n) + 10^kappa` so it cannot overflow. - // - TC3b: TC3 becomes `z(n) <= -z(n+1)`, i.e. `plus1v_up - plus1w(n) >= + // - TC3b: TC3 becomes `z(n) <= -z(n+1)`, i.e., `plus1v_up - plus1w(n) >= // plus1w(n+1) - plus1v_up = plus1w(n) + 10^kappa - plus1v_up`. the negated TC1 // gives `plus1v_up > plus1w(n)`, so it cannot overflow or underflow when // combined with TC3a. @@ -414,7 +414,7 @@ pub fn format_shortest_opt(d: &Decoded, // now we have the closest representation to `v` between `plus1` and `minus1`. // this is too liberal, though, so we reject any `w(n)` not between `plus0` and `minus0`, - // i.e. `plus1 - plus1w(n) <= minus0` or `plus1 - plus1w(n) >= plus0`. we utilize the facts + // i.e., `plus1 - plus1w(n) <= minus0` or `plus1 - plus1w(n) >= plus0`. we utilize the facts // that `threshold = plus1 - minus1` and `plus1 - plus0 = minus0 - minus1 = 2 ulp`. if 2 * ulp <= plus1w && plus1w <= threshold - 4 * ulp { Some((buf.len(), exp)) @@ -675,7 +675,7 @@ pub fn format_exact_opt(d: &Decoded, buf: &mut [u8], limit: i16) return Some((len, exp)); } - // otherwise we are doomed (i.e. some values between `v - 1 ulp` and `v + 1 ulp` are + // otherwise we are doomed (i.e., some values between `v - 1 ulp` and `v + 1 ulp` are // rounding down and others are rounding up) and give up. None } diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 7f5d596b220..13b422162f3 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -1544,7 +1544,7 @@ assert_eq!(", stringify!($SelfT), "::MIN.overflowing_mod_euc(-1), (0, true)); concat!("Negates self, overflowing if this is equal to the minimum value. Returns a tuple of the negated version of self along with a boolean indicating whether an overflow -happened. If `self` is the minimum value (e.g. `i32::MIN` for values of type `i32`), then the +happened. If `self` is the minimum value (e.g., `i32::MIN` for values of type `i32`), then the minimum value will be returned again and `true` will be returned for an overflow happening. # Examples @@ -1621,7 +1621,7 @@ $EndFeature, " concat!("Computes the absolute value of `self`. Returns a tuple of the absolute version of self along with a boolean indicating whether an overflow -happened. If self is the minimum value (e.g. ", stringify!($SelfT), "::MIN for values of type +happened. If self is the minimum value (e.g., ", stringify!($SelfT), "::MIN for values of type ", stringify!($SelfT), "), then the minimum value will be returned again and true will be returned for an overflow happening. @@ -3617,7 +3617,7 @@ assert!(!10", stringify!($SelfT), ".is_power_of_two());", $EndFeature, " doc_comment! { concat!("Returns the smallest power of two greater than or equal to `self`. -When return value overflows (i.e. `self > (1 << (N-1))` for type +When return value overflows (i.e., `self > (1 << (N-1))` for type `uN`), it panics in debug mode and return value is wrapped to 0 in release mode (the only situation in which method can return 0). @@ -4827,7 +4827,7 @@ fn from_str_radix<T: FromStrRadixHelper>(src: &str, radix: u32) -> Result<T, Par /// # Potential causes /// /// Among other causes, `ParseIntError` can be thrown because of leading or trailing whitespace -/// in the string e.g. when it is obtained from the standard input. +/// in the string e.g., when it is obtained from the standard input. /// Using the [`str.trim()`] method ensures that no whitespace remains before parsing. /// /// [`str.trim()`]: ../../std/primitive.str.html#method.trim diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs index 00134a58d30..94dd657ec97 100644 --- a/src/libcore/num/wrapping.rs +++ b/src/libcore/num/wrapping.rs @@ -865,7 +865,7 @@ assert!(!Wrapping(10", stringify!($t), ").is_power_of_two()); doc_comment! { concat!("Returns the smallest power of two greater than or equal to `self`. -When return value overflows (i.e. `self > (1 << (N-1))` for type +When return value overflows (i.e., `self > (1 << (N-1))` for type `uN`), overflows to `2^N = 0`. # Examples |
