IntRootRem
Description
Compute an integer root and the leftover remainder.
Parameters
| Name | Direction | Description |
|---|---|---|
root |
out | Destination for the root |
remainder |
out | Destination for the remainder |
value |
in | Input value |
degree |
in | Root degree |
Usage example (from documentation)
IntRootRem(&root, &rem, &value, 3);Success
Returns true. *root holds floor(value^(1/degree)), *remainder holds value - root^degree.
Failure
Returns false on degree == 0 or allocator OOM. *root / *remainder are left untouched.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Int.c:1695:
}
bool IntRootRem(Int *root, Int *remainder, const Int *value, u64 degree) {
ValidateInt(root);
ValidateInt(remainder);- In
Int.c:1871:
Int remainder = IntInit(IntAllocator(result));
if (!IntRootRem(&root, &remainder, value, degree)) {
IntDeinit(&root);
IntDeinit(&remainder);- In
Int.c:1883:
bool IntSqrtRem(Int *root, Int *remainder, const Int *value) {
return IntRootRem(root, remainder, value, 2);
}- In
Int.c:1927:
bool exact = false;
if (!IntRootRem(&root, &remainder, value, degree)) {
IntDeinit(&root);
IntDeinit(&remainder);- In
Int.Math.c:535:
bool test_int_root_rem(void) {
WriteFmt("Testing IntRootRem\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Math.c:543:
Int remainder = IntInit(&alloc.base);
IntRootRem(&root, &remainder, &value, 3);
bool result = IntToU64(&root) == 5;- In
Int.Math.c:1003:
Int root = IntFrom(99, &alloc.base);
Int remainder = IntFrom(77, &alloc.base);
bool result = !IntRootRem(&root, &remainder, &value, 0);
result = result && (IntCompare(&root, 99) == 0);
Last updated on