IntSqrtRem
Description
Compute the integer square root and remainder.
Parameters
| Name | Direction | Description |
|---|---|---|
root |
out | Destination for the root |
remainder |
out | Destination for the remainder |
value |
in | Input value |
Usage example (from documentation)
IntSqrtRem(&root, &rem, &value);Success
Returns true. *root holds floor(sqrt(value)), *remainder holds value - root^2.
Failure
Returns false on allocator OOM. *root / *remainder are left untouched.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Int.c:1882:
}
bool IntSqrtRem(Int *root, Int *remainder, const Int *value) {
return IntRootRem(root, remainder, value, 2);
}- In
Int.c:1897:
bool result = false;
if (!IntSqrtRem(&root, &remainder, value)) {
IntDeinit(&root);
IntDeinit(&remainder);- In
Int.Math.c:574:
bool test_int_sqrt_rem(void) {
WriteFmt("Testing IntSqrtRem\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Math.c:582:
Int remainder = IntInit(&alloc.base);
IntSqrtRem(&root, &remainder, &value);
bool result = IntToU64(&root) == 14;
Last updated on