Skip to content

Commit 0d62bc0

Browse files
committed
Upgrade num
1 parent d00243a commit 0d62bc0

5 files changed

Lines changed: 9 additions & 9 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ criterion = "0.2"
2222
[dependencies]
2323
bimap = { version = "0.4.0" }
2424
itertools = { version = "0.8.0" }
25-
num = { version = "0.2.0", features = ["rand"] }
26-
num-traits = { version = "0.2.8" }
25+
num = { version = "0.4.0", features = ["rand"] }
26+
num-traits = { version = "0.2.14" }
2727

2828
[[bench]]
2929
name = "nth_root"

src/binary_arithmetic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl<F: Field> GadgetBuilder<F> {
4141
let max_term = (BigUint::one() << term.len()) - BigUint::one();
4242
max_sum += max_term;
4343
}
44-
let sum_bits = max_sum.bits();
44+
let sum_bits = max_sum.bits() as usize;
4545

4646
// TODO: Generalize this addition function to support larger operands.
4747
// We can split the bits into chunks and perform addition on joined chunks.
@@ -188,4 +188,4 @@ mod tests {
188188
let mut values_0 = binary_unsigned_values!(&x_wire => &BigUint::zero());
189189
assert!(gadget.execute(&mut values_0));
190190
}
191-
}
191+
}

src/field.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl<F: Field> Element<F> {
138138

139139
/// The number of bits needed to encode this particular field element.
140140
pub fn bits(&self) -> usize {
141-
self.to_biguint().bits()
141+
self.to_biguint().bits() as usize
142142
}
143143

144144
/// Return the i'th least significant bit. So, for example, x.bit(0) returns the least

src/lcg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl LCG {
3030
}
3131

3232
pub fn next_biguint(&mut self, limit_exclusive: BigUint) -> BigUint {
33-
let bits = (&limit_exclusive - BigUint::one()).bits();
33+
let bits = (&limit_exclusive - BigUint::one()).bits() as usize;
3434
loop {
3535
let n = self.next_biguint_bits(bits);
3636
if n < limit_exclusive {
@@ -67,4 +67,4 @@ mod tests {
6767
assert_eq!(lcg.next_u32(), 3519870697);
6868
assert_eq!(lcg.next_u32(), 2868466484);
6969
}
70-
}
70+
}

src/wire_values.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<F: Field> WireValues<F> {
4747

4848
pub fn set_binary_unsigned(&mut self, wire: &BinaryWire, value: &BigUint) {
4949
let l = wire.len();
50-
assert!(value.bits() <= l, "Value does not fit");
50+
assert!(value.bits() <= l as u64, "Value does not fit");
5151

5252
for i in 0..l {
5353
let value = ((value >> i) & BigUint::one()).is_one();
@@ -118,4 +118,4 @@ macro_rules! binary_unsigned_values {
118118
values
119119
}
120120
}
121-
}
121+
}

0 commit comments

Comments
 (0)