File tree 1 file changed +1
-20
lines changed
1 file changed +1
-20
lines changed Original file line number Diff line number Diff line change @@ -726,28 +726,9 @@ fn udiv_1e19(n: u128) -> (u128, u64) {
726
726
let quot = if n < 1 << 83 {
727
727
( ( n >> 19 ) as u64 / ( DIV >> 19 ) ) as u128
728
728
} else {
729
- u128_mulhi ( n , FACTOR ) >> 62
729
+ n . widening_mul ( FACTOR ) . 1 >> 62
730
730
} ;
731
731
732
732
let rem = ( n - quot * DIV as u128 ) as u64 ;
733
733
( quot, rem)
734
734
}
735
-
736
- /// Multiply unsigned 128 bit integers, return upper 128 bits of the result
737
- #[ inline]
738
- fn u128_mulhi ( x : u128 , y : u128 ) -> u128 {
739
- let x_lo = x as u64 ;
740
- let x_hi = ( x >> 64 ) as u64 ;
741
- let y_lo = y as u64 ;
742
- let y_hi = ( y >> 64 ) as u64 ;
743
-
744
- // handle possibility of overflow
745
- let carry = ( x_lo as u128 * y_lo as u128 ) >> 64 ;
746
- let m = x_lo as u128 * y_hi as u128 + carry;
747
- let high1 = m >> 64 ;
748
-
749
- let m_lo = m as u64 ;
750
- let high2 = ( x_hi as u128 * y_lo as u128 + m_lo as u128 ) >> 64 ;
751
-
752
- x_hi as u128 * y_hi as u128 + high1 + high2
753
- }
You can’t perform that action at this time.
0 commit comments