IntLog2
IntLog2
Description
Compute floor(log2(value)).
Undefined for zero. This function aborts when called on zero.
Parameters
| Name | Direction | Description |
|---|---|---|
value |
in | Integer to inspect |
Usage example (from documentation)
u64 msb = IntLog2(&value);Returns
Index of the highest set bit.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Int.c:293:
}
u64 IntLog2(Int *value) {
ValidateInt(value);- In
Int.c:1302:
}
u64 max_degree = IntLog2(value);
for (u64 degree = 2; degree <= max_degree; degree++) {- In
Int.Access.c:101:
bool test_int_log2(void) {
WriteFmt("Testing IntLog2\n");
Int value = IntFrom(1025);- In
Int.Access.c:105:
Int value = IntFrom(1025);
bool result = IntLog2(&value) == 10;
IntDeinit(&value);- In
Int.Access.c:148:
bool test_int_log2_zero(void) {
WriteFmt("Testing IntLog2 zero handling\n");
Int value = IntInit();- In
Int.Access.c:152:
Int value = IntInit();
IntLog2(&value);
return false;
}
Last updated on