We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f7199bd commit f0c3374Copy full SHA for f0c3374
src/bigint.rs
@@ -3263,11 +3263,12 @@ impl BigInt {
3263
// Then the two's complement is
3264
// ... 1 !x 1 0 ... 0
3265
// where !x is obtained from x by flipping each bit
3266
- let b = self.data.bit(bit);
3267
- if self.is_negative() && bit > self.data.trailing_zeros().unwrap() {
3268
- !b
+ if bit >= u64::from(big_digit::BITS) * self.len() as u64 {
+ self.is_negative()
+ } else if self.is_negative() && bit > self.data.trailing_zeros().unwrap() {
3269
+ !self.data.bit(bit)
3270
} else {
- b
3271
+ self.data.bit(bit)
3272
}
3273
3274
0 commit comments