Skip to content

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)
    }
    
    bool IntSqrtRem(Int *root, Int *remainder, const Int *value) {
        return IntRootRem(root, remainder, value, 2);
    }
        bool result    = false;
    
        if (!IntSqrtRem(&root, &remainder, value)) {
            IntDeinit(&root);
            IntDeinit(&remainder);
    
    bool test_int_sqrt_rem(void) {
        WriteFmt("Testing IntSqrtRem\n");
    
        DefaultAllocator alloc = DefaultAllocatorInit();
        Int remainder = IntInit(&alloc.base);
    
        IntSqrtRem(&root, &remainder, &value);
    
        bool result = IntToU64(&root) == 14;
Last updated on