diff --git a/packages/circuits/README.md b/packages/circuits/README.md index b1970856..232f94a6 100644 --- a/packages/circuits/README.md +++ b/packages/circuits/README.md @@ -278,14 +278,14 @@ Constants: Defines a set of constants used across various circom circuits for st
-log2Ceil: Calculates the ceiling of the base 2 logarithm of a given number. +log2Ceil: Calculate log2 of a number and round it up - **[Source](utils/functions.circom#L2-L10)** - **Inputs**: - - `a`: The input number for which the base 2 logarithm ceiling is to be calculated. + - `a`: The input number for which the `ceil(log2())` needs to be calculated. - **Outputs**: - - Returns the smallest integer greater than or equal to the base 2 logarithm of the input number. + - Returns `ceil(log2())` of the input number.
diff --git a/packages/circuits/utils/functions.circom b/packages/circuits/utils/functions.circom index c945a3d5..7c76024f 100644 --- a/packages/circuits/utils/functions.circom +++ b/packages/circuits/utils/functions.circom @@ -1,11 +1,11 @@ pragma circom 2.1.6; /// @function log2Ceil -/// @notice This function actually calculates `ceil(log2(a+2))` +/// @notice Calculate log2 of a number and round it up /// @param a The input value /// @return The result of the log2Ceil function log2Ceil(a) { - var n = a + 1; + var n = a - 1; var r = 0; while (n > 0) {