IntIsPowerOfTwo
Description
Test whether the integer is a power of two (1, 2, 4, 8, …).
Parameters
| Name | Direction | Description |
|---|---|---|
value |
in | Integer to inspect. |
Success
Returns true when the integer is a power of two.
Failure
Returns false for zero or non-power-of-two values.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Int.c:435:
}
bool IntIsPowerOfTwo(const Int *value) {
ValidateInt(value);- In
Int.Access.c:153:
bool test_int_is_power_of_two(void) {
WriteFmt("Testing IntIsPowerOfTwo\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Access.c:164:
IntShiftLeft(&power, 20);
bool result = IntIsPowerOfTwo(&one);
result = result && IntIsPowerOfTwo(&power);
result = result && !IntIsPowerOfTwo(&other);- In
Int.Access.c:165:
bool result = IntIsPowerOfTwo(&one);
result = result && IntIsPowerOfTwo(&power);
result = result && !IntIsPowerOfTwo(&other);
result = result && !IntIsPowerOfTwo(&zero);- In
Int.Access.c:166:
bool result = IntIsPowerOfTwo(&one);
result = result && IntIsPowerOfTwo(&power);
result = result && !IntIsPowerOfTwo(&other);
result = result && !IntIsPowerOfTwo(&zero);- In
Int.Access.c:167:
result = result && IntIsPowerOfTwo(&power);
result = result && !IntIsPowerOfTwo(&other);
result = result && !IntIsPowerOfTwo(&zero);
IntDeinit(&one);
Last updated on