diff --git a/tfhe/src/core_crypto/commons/parameters.rs b/tfhe/src/core_crypto/commons/parameters.rs index 6e648d234b..0eeb5cac3a 100644 --- a/tfhe/src/core_crypto/commons/parameters.rs +++ b/tfhe/src/core_crypto/commons/parameters.rs @@ -137,8 +137,9 @@ pub struct PolynomialSize(pub usize); impl PolynomialSize { /// Return the associated [`PolynomialSizeLog`]. + /// If the polynomial size is not a power of 2, returns the floor of its log2 pub fn log2(&self) -> PolynomialSizeLog { - PolynomialSizeLog((self.0 as f64).log2().ceil() as usize) + PolynomialSizeLog(self.0.ilog2() as usize) } pub fn to_fourier_polynomial_size(&self) -> FourierPolynomialSize {