IntIsPowerOfTwo
IntIsPowerOfTwo
Description
Test whether the integer is a power of two.
Parameters
| Name | Direction | Description |
|---|---|---|
value |
in | Integer to test |
Usage example (from documentation)
bool pow2 = IntIsPowerOfTwo(&value);Returns
true when exactly one bit is set and the value is non-zero.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Int.c:337:
}
bool IntIsPowerOfTwo(Int *value) {
ValidateInt(value);- In
Int.Access.c:126:
bool test_int_is_power_of_two(void) {
WriteFmt("Testing IntIsPowerOfTwo\n");
Int one = IntFrom(1);- In
Int.Access.c:135:
IntShiftLeft(&power, 20);
bool result = IntIsPowerOfTwo(&one);
result = result && IntIsPowerOfTwo(&power);
result = result && !IntIsPowerOfTwo(&other);- In
Int.Access.c:136:
bool result = IntIsPowerOfTwo(&one);
result = result && IntIsPowerOfTwo(&power);
result = result && !IntIsPowerOfTwo(&other);
result = result && !IntIsPowerOfTwo(&zero);- In
Int.Access.c:137:
bool result = IntIsPowerOfTwo(&one);
result = result && IntIsPowerOfTwo(&power);
result = result && !IntIsPowerOfTwo(&other);
result = result && !IntIsPowerOfTwo(&zero);- In
Int.Access.c:138:
result = result && IntIsPowerOfTwo(&power);
result = result && !IntIsPowerOfTwo(&other);
result = result && !IntIsPowerOfTwo(&zero);
IntDeinit(&one);
Last updated on