Skip to content

Commit 38f2eeb

Browse files
committed
Fix overflow error
1 parent f416051 commit 38f2eeb

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ impl MT19937 {
126126
while k != 0 {
127127
self.mt[i] = (self.mt[i]
128128
^ ((self.mt[i - 1] ^ (self.mt[i - 1] >> 30)).wrapping_mul(1664525u32)))
129-
+ init_key[j]
130-
+ j as u32; /* non linear */
129+
.wrapping_add(init_key[j])
130+
.wrapping_add(j as u32); /* non linear */
131131
self.mt[i] &= 0xffffffffu32; /* for WORDSIZE > 32 machines */
132132
i += 1;
133133
j += 1;
@@ -144,7 +144,7 @@ impl MT19937 {
144144
while k != 0 {
145145
self.mt[i] = (self.mt[i]
146146
^ ((self.mt[i - 1] ^ (self.mt[i - 1] >> 30)).wrapping_mul(1566083941u32)))
147-
- i as u32; /* non linear */
147+
.wrapping_sub(i as u32); /* non linear */
148148
self.mt[i] &= 0xffffffffu32; /* for WORDSIZE > 32 machines */
149149
i += 1;
150150
if i >= N {

0 commit comments

Comments
 (0)