diff --git a/substrate/primitives/arithmetic/src/helpers_128bit.rs b/substrate/primitives/arithmetic/src/helpers_128bit.rs index 260f90ed60..11df8bd531 100644 --- a/substrate/primitives/arithmetic/src/helpers_128bit.rs +++ b/substrate/primitives/arithmetic/src/helpers_128bit.rs @@ -358,8 +358,8 @@ mod tests { fn op_checked_rounded_div_works() { for i in 0..100_000u32 { let a = random_u128(i); - let b = random_u128(i + 1 << 30); - let c = random_u128(i + 1 << 31); + let b = random_u128(i + (1 << 30)); + let c = random_u128(i + (1 << 31)); let x = mulrat(a, b, c, NearestPrefDown); let y = multiply_by_rational(a, b, c).ok(); assert_eq!(x.is_some(), y.is_some()); diff --git a/substrate/primitives/arithmetic/src/per_things.rs b/substrate/primitives/arithmetic/src/per_things.rs index 7f39d35774..2932a74206 100644 --- a/substrate/primitives/arithmetic/src/per_things.rs +++ b/substrate/primitives/arithmetic/src/per_things.rs @@ -639,8 +639,9 @@ macro_rules! implement_per_thing { write!(fmt, "{:.2}% ({}/{})", pc, self.0, $max) } else { // A power of ten: calculate exact percent - let units = self.0 / ($max / 100); - let rest = self.0 % ($max / 100); + let divisor = $max / 100; + let units = self.0 / divisor; + let rest = self.0 % divisor; write!(fmt, "{}", units)?; if rest > 0 { write!(fmt, ".")?;