File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -43,10 +43,10 @@ impl<const LIMBS: usize> Uint<LIMBS> {
43
43
let shift_num = ( shift / Limb :: BITS ) as usize ;
44
44
let rem = shift % Limb :: BITS ;
45
45
46
- let mut i = LIMBS ;
47
- while i > shift_num {
48
- i -= 1 ;
46
+ let mut i = shift_num;
47
+ while i < LIMBS {
49
48
limbs[ i] = self . limbs [ i - shift_num] ;
49
+ i += 1 ;
50
50
}
51
51
52
52
if rem == 0 {
@@ -55,6 +55,7 @@ impl<const LIMBS: usize> Uint<LIMBS> {
55
55
56
56
let mut carry = Limb :: ZERO ;
57
57
58
+ let mut i = shift_num;
58
59
while i < LIMBS {
59
60
let shifted = limbs[ i] . shl ( rem) ;
60
61
let new_carry = limbs[ i] . shr ( Limb :: BITS - rem) ;
@@ -104,15 +105,15 @@ impl<const LIMBS: usize> Uint<LIMBS> {
104
105
let rshift = nz. if_true_u32 ( Limb :: BITS - shift) ;
105
106
let carry = nz. if_true_word ( self . limbs [ LIMBS - 1 ] . 0 . wrapping_shr ( Word :: BITS - shift) ) ;
106
107
107
- let mut i = LIMBS - 1 ;
108
- while i > 0 {
108
+ limbs[ 0 ] = Limb ( self . limbs [ 0 ] . 0 << lshift) ;
109
+ let mut i = 1 ;
110
+ while i < LIMBS {
109
111
let mut limb = self . limbs [ i] . 0 << lshift;
110
112
let hi = self . limbs [ i - 1 ] . 0 >> rshift;
111
113
limb |= nz. if_true_word ( hi) ;
112
114
limbs[ i] = Limb ( limb) ;
113
- i - = 1
115
+ i + = 1
114
116
}
115
- limbs[ 0 ] = Limb ( self . limbs [ 0 ] . 0 << lshift) ;
116
117
117
118
( Uint :: < LIMBS > :: new ( limbs) , Limb ( carry) )
118
119
}
You can’t perform that action at this time.
0 commit comments