Skip to content

Commit

Permalink
circuit: fix log2Ceil
Browse files Browse the repository at this point in the history
  • Loading branch information
saleel committed May 20, 2024
1 parent 27ccace commit 9917437
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/circuits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,14 @@ Constants: Defines a set of constants used across various circom circuits for st

<details>
<summary>
log2Ceil: Calculates the ceiling of the base 2 logarithm of a given number.
log2Ceil: Calculate log2 of a number and round it up
</summary>

- **[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.
</details>


Expand Down
4 changes: 2 additions & 2 deletions packages/circuits/utils/functions.circom
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down

0 comments on commit 9917437

Please sign in to comment.