This commit is contained in:
wborgeaud 2022-09-14 06:19:06 +02:00
parent 2a37aeca5d
commit 0aecc2a3cf
2 changed files with 3 additions and 3 deletions

View File

@ -34,7 +34,7 @@ impl<const B: usize> BaseSumGate<B> {
pub fn new_from_config<F: Field64>(config: &CircuitConfig) -> Self {
let num_limbs =
log_floor(F::ORDER as usize, B).min(config.num_routed_wires - Self::START_LIMBS);
log_floor(F::ORDER as usize - 1, B).min(config.num_routed_wires - Self::START_LIMBS);
Self::new(num_limbs)
}

View File

@ -38,7 +38,7 @@ pub fn log2_strict(n: usize) -> usize {
res as usize
}
/// Returns the largest `i` such that `base**i < n`.
/// Returns the largest integer `i` such that `base**i <= n`.
pub const fn log_floor(n: usize, base: usize) -> usize {
assert!(n > 0);
assert!(base > 1);
@ -46,7 +46,7 @@ pub const fn log_floor(n: usize, base: usize) -> usize {
let mut cur: usize = 1;
loop {
let (mul, overflow) = cur.overflowing_mul(base);
if overflow || mul >= n {
if overflow || mul > n {
return i;
} else {
i += 1;