IntIsPerfectSquare
Description
Test whether a value is a perfect square.
Parameters
| Name | Direction | Description |
|---|---|---|
value |
in | Value to test |
Usage example (from documentation)
bool square = IntIsPerfectSquare(&value);Success
Returns true when value = n^2 for some integer n.
Failure
Returns false otherwise.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Int.c:2187:
}
bool IntIsPerfectSquare(const Int *value) {
ValidateInt(value);- In
Math.c:605:
bool test_int_is_perfect_square(void) {
WriteFmt("Testing IntIsPerfectSquare\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Math.c:612:
Int non_square = IntFrom(145, &alloc.base);
bool result = IntIsPerfectSquare(&square);
result = result && !IntIsPerfectSquare(&non_square);- In
Math.c:613:
bool result = IntIsPerfectSquare(&square);
result = result && !IntIsPerfectSquare(&non_square);
IntDeinit(&square);- In
Math.c:4097:
Int nsq = IntFrom(123202u, a);
bool ok = IntIsPerfectSquare(&sq) && !IntIsPerfectSquare(&nsq);
IntDeinit(&sq);
Last updated on