IntSqrt
Description
Compute the integer square root (floor).
Parameters
| Name | Direction | Description |
|---|---|---|
result |
out | Destination for the root |
value |
in | Input value |
Usage example (from documentation)
IntSqrt(&root, &value);Success
Returns true. *result holds floor(sqrt(value)).
Failure
Returns false on allocator OOM. *result is left untouched.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Int.c:1886:
}
bool IntSqrt(Int *result, const Int *value) {
return IntRoot(result, value, 2);
}- In
Int.Math.c:556:
bool test_int_sqrt(void) {
WriteFmt("Testing IntSqrt\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Math.c:563:
Int result_value = IntInit(&alloc.base);
IntSqrt(&result_value, &value);
bool result = IntToU64(&result_value) == 14;
Last updated on