remove use of bigint
@@ -143,15 +143,22 @@ pub fn as_mixed_radix(x: u128, radii: &[u16]) -> Vec<u16> {
/// Convert little-endian base `q` digits into `u128`.
pub fn from_base_q(ds: &[u16], q: u16) -> u128 {
- let mut x = bigint::uint::U256::zero();
+ let mut x = 0u128;
for &d in ds.iter().rev() {
- let (xp, overflow) = x.overflowing_mul(bigint::uint::U256::from(q));
+ let (xp, overflow) = x.overflowing_mul(q.into());
debug_assert_eq!(overflow, false, "overflow!!!! x={}", x);
- x = xp + bigint::uint::U256::from(d);
+ x = xp + d as u128;
}
- let b0 = x.0[0] as u128;
- let b1 = x.0[1] as u128;
- (b1 << 64) + b0
+ x
+ // let mut x = bigint::uint::U256::zero();
+ // for &d in ds.iter().rev() {
+ // let (xp, overflow) = x.overflowing_mul(bigint::uint::U256::from(q));
+ // debug_assert_eq!(overflow, false, "overflow!!!! x={}", x);
+ // x = xp + bigint::uint::U256::from(d);
+ // }
+ // let b0 = x.0[0] as u128;
+ // let b1 = x.0[1] as u128;
+ // (b1 << 64) + b0
}
/// Convert little-endian mixed radix digits into u128.
