Skip to content

IntFrom

Description

Convert a native integer into an arbitrary-precision integer. Dispatches on the type of value.

Aborts when a signed input is negative.

Parameters

Name Direction Description
value in Signed or unsigned integer source value

Usage example (from documentation)

  Int value = IntFrom(1234u);

Success

Returns Integer holding the same non-negative value.

Failure

LOG_FATAL when a signed value is negative (the non-negative IntFrom contract is violated). Allocator failures on the underlying construction abort through the allocator’s standard failure path.

Usage example (Cross-references)

Usage examples (Cross-references)
    
        Int zero     = IntInit(&alloc.base);
        Int non_zero = IntFrom(1, &alloc.base);
    
        bool result = IntIsZero(&zero);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int one = IntFrom(1, &alloc.base);
        Int two = IntFrom(2, &alloc.base);
    
        Int one = IntFrom(1, &alloc.base);
        Int two = IntFrom(2, &alloc.base);
    
        bool result = IntIsOne(&one);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int even = IntFrom(42, &alloc.base);
        Int odd  = IntFrom(43, &alloc.base);
    
        Int even = IntFrom(42, &alloc.base);
        Int odd  = IntFrom(43, &alloc.base);
    
        bool result = IntIsEven(&even);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int small = IntFrom(UINT64_MAX, &alloc.base);
        Int big   = IntFrom(1, &alloc.base);
    
        Int small = IntFrom(UINT64_MAX, &alloc.base);
        Int big   = IntFrom(1, &alloc.base);
    
        IntShiftLeft(&big, 64);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int  value = IntFrom(1025, &alloc.base);
        bool error = true;
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int one   = IntFrom(1, &alloc.base);
        Int power = IntFrom(1, &alloc.base);
        Int other = IntFrom(24, &alloc.base);
    
        Int one   = IntFrom(1, &alloc.base);
        Int power = IntFrom(1, &alloc.base);
        Int other = IntFrom(24, &alloc.base);
        Int zero  = IntInit(&alloc.base);
        Int one   = IntFrom(1, &alloc.base);
        Int power = IntFrom(1, &alloc.base);
        Int other = IntFrom(24, &alloc.base);
        Int zero  = IntInit(&alloc.base);
    
    bool test_int_from_unsigned_integer(void) {
        WriteFmt("Testing IntFrom with unsigned integer\n");
    
        DefaultAllocator alloc = DefaultAllocatorInit();
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int value = IntFrom(13, ALLOCATOR_OF(&alloc));
        Str text  = IntToBinary(&value);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int value = IntFrom(0xBEEF, ALLOCATOR_OF(&alloc));
        Str text  = IntToStrRadix(&value, 16, true);
        alloc.base.retry_limit = 4;
    
        Int value = IntFrom(0xBEEF, ALLOCATOR_OF(&alloc));
    
        ok = int_try_to_str_radix(&text, &value, 16, true, ALLOCATOR_OF(&alloc));
    
        Int lhs = IntFromBinary("0001011", ALLOCATOR_OF(&alloc));
        Int rhs = IntFrom(11, ALLOCATOR_OF(&alloc));
    
        bool result = IntCompare(&lhs, &rhs) == 0;
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int  value = IntFrom(1, ALLOCATOR_OF(&alloc));
        u64  out   = 0;
        bool error = false;
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int value = IntFrom(255, ALLOCATOR_OF(&alloc));
        Str text  = IntToStrRadix(&value, 37, false);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int value = IntFrom(1, ALLOCATOR_OF(&alloc));
        IntToBytesLE(&value, NULL, 1);
        DefaultAllocatorDeinit(&alloc);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int value = IntFrom(1, ALLOCATOR_OF(&alloc));
        u8  byte  = 0;
        Float value = FloatFromStr("12.5", &alloc.base);
        Float same  = FloatFromStr("12.5", &alloc.base);
        Int   whole = IntFrom(12, &alloc.base);
        Int   next  = IntFrom(13, &alloc.base);
        Float same  = FloatFromStr("12.5", &alloc.base);
        Int   whole = IntFrom(12, &alloc.base);
        Int   next  = IntFrom(13, &alloc.base);
    
        bool result = (FloatCompare(&value, &same) == 0);
    
        Float value        = FloatFromStr("123.45", ALLOCATOR_OF(&alloc));
        Int   result_value = IntFrom(99, ALLOCATOR_OF(&alloc));
    
        bool result = !FloatToInt(&result_value, &value);
    
        Float value        = FloatFromStr("-42", ALLOCATOR_OF(&alloc));
        Int   result_value = IntFrom(99, ALLOCATOR_OF(&alloc));
    
        bool result = !FloatToInt(&result_value, &value);
        Int hex_val = IntFromHexStr("deadbeefcafebabe1234", alloc_base);
        Int bin_val = IntFromBinary("10100011", alloc_base);
        Int oct_val = IntFrom(493, alloc_base);
    
        StrAppendFmt(&output, "{}", big_dec);
        Float a            = FloatFromStr("1.25", &alloc.base);
        Float b            = FloatFromStr("0.75", &alloc.base);
        Int   whole        = IntFrom(2, &alloc.base);
        Float result_value = FloatInit(&alloc.base);
        Str   text         = StrInit(&alloc.base);
        Float a            = FloatFromStr("5.5", &alloc.base);
        Float b            = FloatFromStr("0.5", &alloc.base);
        Int   whole        = IntFrom(2, &alloc.base);
        Float result_value = FloatInit(&alloc.base);
        Str   text         = StrInit(&alloc.base);
        Float a            = FloatFromStr("1.5", &alloc.base);
        Float b            = FloatFromStr("2", &alloc.base);
        Int   whole        = IntFrom(2, &alloc.base);
        Float result_value = FloatInit(&alloc.base);
        Str   text         = StrInit(&alloc.base);
        Float a            = FloatFromStr("7.5", &alloc.base);
        Float b            = FloatFromStr("2.5", &alloc.base);
        Int   whole        = IntFrom(3, &alloc.base);
        Float result_value = FloatInit(&alloc.base);
        Str   text         = StrInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int a = IntFrom(41, &alloc.base);
        Int b = IntFrom(42, &alloc.base);
        Int c = IntFromBinary("000101010", &alloc.base);
    
        Int a = IntFrom(41, &alloc.base);
        Int b = IntFrom(42, &alloc.base);
        Int c = IntFromBinary("000101010", &alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int a = IntFrom(41, &alloc.base);
        Int b = IntFrom(42, &alloc.base);
        Int c = IntFromBinary("000101010", &alloc.base);
    
        Int a = IntFrom(41, &alloc.base);
        Int b = IntFrom(42, &alloc.base);
        Int c = IntFromBinary("000101010", &alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int value = IntFrom(42, &alloc.base);
        Int same  = IntFromBinary("00101010", &alloc.base);
        Int big   = IntFrom(1, &alloc.base);
        Int value = IntFrom(42, &alloc.base);
        Int same  = IntFromBinary("00101010", &alloc.base);
        Int big   = IntFrom(1, &alloc.base);
    
        IntShiftLeft(&big, 80);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int a = IntFrom(42u, &alloc.base);
        Int b = IntFromBinary("101010", &alloc.base);
        Int c = IntFrom(0u, &alloc.base);
        Int a = IntFrom(42u, &alloc.base);
        Int b = IntFromBinary("101010", &alloc.base);
        Int c = IntFrom(0u, &alloc.base);
        Int d = IntFrom(0u, &alloc.base);
        Int b = IntFromBinary("101010", &alloc.base);
        Int c = IntFrom(0u, &alloc.base);
        Int d = IntFrom(0u, &alloc.base);
    
        bool result = (int_hash(&a, 0) == int_hash(&b, 0));
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int zero  = IntFrom(0u, &alloc.base);
        Int one   = IntFrom(1u, &alloc.base);
        Int small = IntFrom(42u, &alloc.base);
    
        Int zero  = IntFrom(0u, &alloc.base);
        Int one   = IntFrom(1u, &alloc.base);
        Int small = IntFrom(42u, &alloc.base);
        Int large = IntFrom(1u, &alloc.base);
        Int zero  = IntFrom(0u, &alloc.base);
        Int one   = IntFrom(1u, &alloc.base);
        Int small = IntFrom(42u, &alloc.base);
        Int large = IntFrom(1u, &alloc.base);
        IntShiftLeft(&large, 80);
        Int one   = IntFrom(1u, &alloc.base);
        Int small = IntFrom(42u, &alloc.base);
        Int large = IntFrom(1u, &alloc.base);
        IntShiftLeft(&large, 80);
        Int decimal = IntFromStr("12345678901234567890", &alloc.base);
        Map(Int, u64) counts = MapInit(int_hash, int_compare, &alloc);
    
        Int k1 = IntFrom(100u, &alloc.base);
        Int k2 = IntFrom(200u, &alloc.base);
        Int k3 = IntFrom(100u, &alloc.base); // duplicate of k1 by value
    
        Int k1 = IntFrom(100u, &alloc.base);
        Int k2 = IntFrom(200u, &alloc.base);
        Int k3 = IntFrom(100u, &alloc.base); // duplicate of k1 by value
        Int k1 = IntFrom(100u, &alloc.base);
        Int k2 = IntFrom(200u, &alloc.base);
        Int k3 = IntFrom(100u, &alloc.base); // duplicate of k1 by value
    
        MapInsertR(&counts, k1, 1u);
        MapInsertR(&counts, k2, 2u);
    
        Int  probe   = IntFrom(100u, &alloc.base);
        u64 *got     = MapGetFirstPtr(&counts, probe);
        Int  missing = IntFrom(999u, &alloc.base);
        Int  probe   = IntFrom(100u, &alloc.base);
        u64 *got     = MapGetFirstPtr(&counts, probe);
        Int  missing = IntFrom(999u, &alloc.base);
        u64 *gone    = MapGetFirstPtr(&counts, missing);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int value = IntFrom(3, &alloc.base);
    
        IntShiftLeft(&value, 4);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int a            = IntFrom(255, &alloc.base);
        Int b            = IntFrom(1, &alloc.base);
        Int result_value = IntInit(&alloc.base);
    
        Int a            = IntFrom(255, &alloc.base);
        Int b            = IntFrom(1, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        Str text         = StrInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int base         = IntFrom(40, &alloc.base);
        Int rhs          = IntFrom(2, &alloc.base);
        Int result_value = IntInit(&alloc.base);
    
        Int base         = IntFrom(40, &alloc.base);
        Int rhs          = IntFrom(2, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        Int huge         = IntFromStr("123456789012345678901234567890", &alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int a            = IntFrom(256, &alloc.base);
        Int b            = IntFrom(1, &alloc.base);
        Int result_value = IntInit(&alloc.base);
    
        Int a            = IntFrom(256, &alloc.base);
        Int b            = IntFrom(1, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int base         = IntFrom(40, &alloc.base);
        Int rhs          = IntFrom(2, &alloc.base);
        Int result_value = IntInit(&alloc.base);
    
        Int base         = IntFrom(40, &alloc.base);
        Int rhs          = IntFrom(2, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        Int preserved    = IntFrom(99, &alloc.base);
        Int rhs          = IntFrom(2, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        Int preserved    = IntFrom(99, &alloc.base);
        Int huge         = IntFromStr("12345678901234567890", &alloc.base);
        Str text         = StrInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int a            = IntFrom(3, &alloc.base);
        Int b            = IntFrom(5, &alloc.base);
        Int result_value = IntFrom(99, &alloc.base);
    
        Int a            = IntFrom(3, &alloc.base);
        Int b            = IntFrom(5, &alloc.base);
        Int result_value = IntFrom(99, &alloc.base);
        Int a            = IntFrom(3, &alloc.base);
        Int b            = IntFrom(5, &alloc.base);
        Int result_value = IntFrom(99, &alloc.base);
    
        bool result = !IntSub(&result_value, &a, &b);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int a            = IntFrom(21, &alloc.base);
        Int b            = IntFrom(6, &alloc.base);
        Int result_value = IntInit(&alloc.base);
    
        Int a            = IntFrom(21, &alloc.base);
        Int b            = IntFrom(6, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int a            = IntFrom(0, &alloc.base);
        Int b            = IntFrom(12345, &alloc.base);
        Int result_value = IntInit(&alloc.base);
    
        Int a            = IntFrom(0, &alloc.base);
        Int b            = IntFrom(12345, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int value        = IntFrom(12345, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int base         = IntFrom(7, &alloc.base);
        Int exponent     = IntFrom(20, &alloc.base);
        Int result_value = IntInit(&alloc.base);
    
        Int base         = IntFrom(7, &alloc.base);
        Int exponent     = IntFrom(20, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        Str text         = StrInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int dividend     = IntFrom(126, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int dividend     = IntFrom(10, &alloc.base);
        Int divisor      = IntFrom(3, &alloc.base);
        Int result_value = IntFrom(99, &alloc.base);
    
        Int dividend     = IntFrom(10, &alloc.base);
        Int divisor      = IntFrom(3, &alloc.base);
        Int result_value = IntFrom(99, &alloc.base);
        Int dividend     = IntFrom(10, &alloc.base);
        Int divisor      = IntFrom(3, &alloc.base);
        Int result_value = IntFrom(99, &alloc.base);
    
        bool result = !IntDivExact(&result_value, &dividend, &divisor);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int dividend     = IntFrom(126, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int a            = IntFrom(48, &alloc.base);
        Int b            = IntFrom(18, &alloc.base);
        Int result_value = IntInit(&alloc.base);
    
        Int a            = IntFrom(48, &alloc.base);
        Int b            = IntFrom(18, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int a            = IntFrom(21, &alloc.base);
        Int b            = IntFrom(6, &alloc.base);
        Int result_value = IntInit(&alloc.base);
    
        Int a            = IntFrom(21, &alloc.base);
        Int b            = IntFrom(6, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int value        = IntFrom(4096, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int value     = IntFrom(200, &alloc.base);
        Int root      = IntInit(&alloc.base);
        Int remainder = IntInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int value        = IntFrom(200, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int value     = IntFrom(200, &alloc.base);
        Int root      = IntInit(&alloc.base);
        Int remainder = IntInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int square     = IntFrom(144, &alloc.base);
        Int non_square = IntFrom(145, &alloc.base);
    
        Int square     = IntFrom(144, &alloc.base);
        Int non_square = IntFrom(145, &alloc.base);
    
        bool result = IntIsPerfectSquare(&square);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int power     = IntFrom(81, &alloc.base);
        Int non_power = IntFrom(82, &alloc.base);
        Int one       = IntFrom(1, &alloc.base);
    
        Int power     = IntFrom(81, &alloc.base);
        Int non_power = IntFrom(82, &alloc.base);
        Int one       = IntFrom(1, &alloc.base);
        Int power     = IntFrom(81, &alloc.base);
        Int non_power = IntFrom(82, &alloc.base);
        Int one       = IntFrom(1, &alloc.base);
    
        bool result = IntIsPerfectPower(&power);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int a = IntFrom(5, &alloc.base);
        Int p = IntFrom(7, &alloc.base);
        Int b = IntFrom(9, &alloc.base);
    
        Int a = IntFrom(5, &alloc.base);
        Int p = IntFrom(7, &alloc.base);
        Int b = IntFrom(9, &alloc.base);
        Int n = IntFrom(21, &alloc.base);
        Int a = IntFrom(5, &alloc.base);
        Int p = IntFrom(7, &alloc.base);
        Int b = IntFrom(9, &alloc.base);
        Int n = IntFrom(21, &alloc.base);
        Int p = IntFrom(7, &alloc.base);
        Int b = IntFrom(9, &alloc.base);
        Int n = IntFrom(21, &alloc.base);
    
        bool result = IntJacobi(&a, &p) == -1;
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int value        = IntFrom(12345, &alloc.base);
        Int mod          = IntFrom(97, &alloc.base);
        Int result_value = IntInit(&alloc.base);
    
        Int value        = IntFrom(12345, &alloc.base);
        Int mod          = IntFrom(97, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int a            = IntFrom(100, &alloc.base);
        Int b            = IntFrom(250, &alloc.base);
        Int m            = IntFrom(13, &alloc.base);
    
        Int a            = IntFrom(100, &alloc.base);
        Int b            = IntFrom(250, &alloc.base);
        Int m            = IntFrom(13, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        Int a            = IntFrom(100, &alloc.base);
        Int b            = IntFrom(250, &alloc.base);
        Int m            = IntFrom(13, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int a            = IntFrom(5, &alloc.base);
        Int b            = IntFrom(9, &alloc.base);
        Int m            = IntFrom(13, &alloc.base);
    
        Int a            = IntFrom(5, &alloc.base);
        Int b            = IntFrom(9, &alloc.base);
        Int m            = IntFrom(13, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        Int a            = IntFrom(5, &alloc.base);
        Int b            = IntFrom(9, &alloc.base);
        Int m            = IntFrom(13, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int a            = IntFrom(123, &alloc.base);
        Int b            = IntFrom(456, &alloc.base);
        Int m            = IntFrom(97, &alloc.base);
    
        Int a            = IntFrom(123, &alloc.base);
        Int b            = IntFrom(456, &alloc.base);
        Int m            = IntFrom(97, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        Int a            = IntFrom(123, &alloc.base);
        Int b            = IntFrom(456, &alloc.base);
        Int m            = IntFrom(97, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int a            = IntFrom(10, &alloc.base);
        Int b            = IntFrom(3, &alloc.base);
        Int m            = IntFrom(13, &alloc.base);
    
        Int a            = IntFrom(10, &alloc.base);
        Int b            = IntFrom(3, &alloc.base);
        Int m            = IntFrom(13, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        Int a            = IntFrom(10, &alloc.base);
        Int b            = IntFrom(3, &alloc.base);
        Int m            = IntFrom(13, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        Int check        = IntInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int base         = IntFrom(7, &alloc.base);
        Int mod          = IntFrom(13, &alloc.base);
        Int result_value = IntInit(&alloc.base);
    
        Int base         = IntFrom(7, &alloc.base);
        Int mod          = IntFrom(13, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int base         = IntFrom(4, &alloc.base);
        Int exp          = IntFrom(13, &alloc.base);
        Int mod          = IntFrom(497, &alloc.base);
    
        Int base         = IntFrom(4, &alloc.base);
        Int exp          = IntFrom(13, &alloc.base);
        Int mod          = IntFrom(497, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        Int base         = IntFrom(4, &alloc.base);
        Int exp          = IntFrom(13, &alloc.base);
        Int mod          = IntFrom(497, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int value        = IntFrom(3, &alloc.base);
        Int mod          = IntFrom(11, &alloc.base);
        Int result_value = IntInit(&alloc.base);
    
        Int value        = IntFrom(3, &alloc.base);
        Int mod          = IntFrom(11, &alloc.base);
        Int result_value = IntInit(&alloc.base);
        Int check        = IntInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int value = IntFrom(10, &alloc.base);
        Int mod   = IntFrom(13, &alloc.base);
        Int root  = IntInit(&alloc.base);
    
        Int value = IntFrom(10, &alloc.base);
        Int mod   = IntFrom(13, &alloc.base);
        Int root  = IntInit(&alloc.base);
        Int check = IntInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int value = IntFrom(3, &alloc.base);
        Int mod   = IntFrom(7, &alloc.base);
        Int root  = IntFrom(99, &alloc.base);
    
        Int value = IntFrom(3, &alloc.base);
        Int mod   = IntFrom(7, &alloc.base);
        Int root  = IntFrom(99, &alloc.base);
        Int value = IntFrom(3, &alloc.base);
        Int mod   = IntFrom(7, &alloc.base);
        Int root  = IntFrom(99, &alloc.base);
    
        bool result = !IntModSqrt(&root, &value, &mod);
    
        Int prime     = IntFromStr("1000000007", &alloc.base);
        Int composite = IntFrom(561, &alloc.base);
    
        bool result = IntIsProbablePrime(&prime);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int value        = IntFrom(6, &alloc.base);
        Int mod          = IntFrom(15, &alloc.base);
        Int result_value = IntFrom(99, &alloc.base);
    
        Int value        = IntFrom(6, &alloc.base);
        Int mod          = IntFrom(15, &alloc.base);
        Int result_value = IntFrom(99, &alloc.base);
        Int value        = IntFrom(6, &alloc.base);
        Int mod          = IntFrom(15, &alloc.base);
        Int result_value = IntFrom(99, &alloc.base);
    
        bool result = !IntModInv(&result_value, &value, &mod);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int a            = IntFrom(1, &alloc.base);
        Int b            = IntFrom(6, &alloc.base);
        Int m            = IntFrom(15, &alloc.base);
    
        Int a            = IntFrom(1, &alloc.base);
        Int b            = IntFrom(6, &alloc.base);
        Int m            = IntFrom(15, &alloc.base);
        Int result_value = IntFrom(99, &alloc.base);
        Int a            = IntFrom(1, &alloc.base);
        Int b            = IntFrom(6, &alloc.base);
        Int m            = IntFrom(15, &alloc.base);
        Int result_value = IntFrom(99, &alloc.base);
        Int b            = IntFrom(6, &alloc.base);
        Int m            = IntFrom(15, &alloc.base);
        Int result_value = IntFrom(99, &alloc.base);
    
        bool result = !IntModDiv(&result_value, &a, &b, &m);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int a = IntFrom(1, &alloc.base);
        Int b = IntFrom(2, &alloc.base);
    
        Int a = IntFrom(1, &alloc.base);
        Int b = IntFrom(2, &alloc.base);
    
        IntAdd(NULL, &a, &b);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int dividend  = IntFrom(1, &alloc.base);
        Int divisor   = IntInit(&alloc.base);
        Int quotient  = IntFrom(99, &alloc.base);
        Int dividend  = IntFrom(1, &alloc.base);
        Int divisor   = IntInit(&alloc.base);
        Int quotient  = IntFrom(99, &alloc.base);
        Int remainder = IntFrom(77, &alloc.base);
        Int divisor   = IntInit(&alloc.base);
        Int quotient  = IntFrom(99, &alloc.base);
        Int remainder = IntFrom(77, &alloc.base);
    
        bool result = !IntDivMod(&quotient, &remainder, &dividend, &divisor);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int  value     = IntFrom(16, &alloc.base);
        Int  root      = IntFrom(99, &alloc.base);
        Int  remainder = IntFrom(77, &alloc.base);
    
        Int  value     = IntFrom(16, &alloc.base);
        Int  root      = IntFrom(99, &alloc.base);
        Int  remainder = IntFrom(77, &alloc.base);
        bool result    = !IntRootRem(&root, &remainder, &value, 0);
        Int  value     = IntFrom(16, &alloc.base);
        Int  root      = IntFrom(99, &alloc.base);
        Int  remainder = IntFrom(77, &alloc.base);
        bool result    = !IntRootRem(&root, &remainder, &value, 0);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int dividend = IntFrom(10, &alloc.base);
        Int quotient = IntFrom(99, &alloc.base);
    
        Int dividend = IntFrom(10, &alloc.base);
        Int quotient = IntFrom(99, &alloc.base);
    
        IntDiv(&quotient, &dividend, 0u);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int value        = IntFrom(10, &alloc.base);
        Int result_value = IntFrom(99, &alloc.base);
    
        Int value        = IntFrom(10, &alloc.base);
        Int result_value = IntFrom(99, &alloc.base);
    
        IntMod(&result_value, &value, 0u);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int a            = IntFrom(10, &alloc.base);
        Int b            = IntFrom(3, &alloc.base);
        Int m            = IntInit(&alloc.base);
    
        Int a            = IntFrom(10, &alloc.base);
        Int b            = IntFrom(3, &alloc.base);
        Int m            = IntInit(&alloc.base);
        Int result_value = IntFrom(99, &alloc.base);
        Int b            = IntFrom(3, &alloc.base);
        Int m            = IntInit(&alloc.base);
        Int result_value = IntFrom(99, &alloc.base);
    
        bool result = !IntModDiv(&result_value, &a, &b, &m);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int  a      = IntFrom(3, &alloc.base);
        Int  n      = IntFrom(8, &alloc.base);
        int  symbol = 99;
    
        Int  a      = IntFrom(3, &alloc.base);
        Int  n      = IntFrom(8, &alloc.base);
        int  symbol = 99;
        bool error  = false;
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int base         = IntFrom(2, &alloc.base);
        Int mod          = IntInit(&alloc.base);
        Int result_value = IntInit(&alloc.base);
        DefaultAllocator alloc = DefaultAllocatorInit();
    
        Int base         = IntFrom(2, &alloc.base);
        Int exp          = IntFrom(8, &alloc.base);
        Int mod          = IntInit(&alloc.base);
    
        Int base         = IntFrom(2, &alloc.base);
        Int exp          = IntFrom(8, &alloc.base);
        Int mod          = IntInit(&alloc.base);
        Int result_value = IntFrom(99, &alloc.base);
        Int exp          = IntFrom(8, &alloc.base);
        Int mod          = IntInit(&alloc.base);
        Int result_value = IntFrom(99, &alloc.base);
    
        bool result = !IntPowMod(&result_value, &base, &exp, &mod);
Last updated on