mirror of
https://github.com/zkemail/zk-email-verify.git
synced 2026-01-09 13:38:03 -05:00
18 lines
298 B
Plaintext
18 lines
298 B
Plaintext
pragma circom 2.1.6;
|
|
|
|
/// @function log2Ceil
|
|
/// @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 r = 0;
|
|
|
|
while (n > 0) {
|
|
r++;
|
|
n \= 2;
|
|
}
|
|
|
|
return r;
|
|
}
|