Skip to content

IntClone

IntClone

Description

Create a deep copy of an integer.

Parameters

Name Direction Description
value in Integer to clone

Usage example (from documentation)

  Int copy = IntClone(&value);

Returns

Independent copy of value.

Usage example (Cross-references)

Usage examples (Cross-references)
        clone.negative    = value->negative;
        clone.exponent    = value->exponent;
        clone.significand = IntClone(&value->significand);
        return clone;
    }
    
        ValidateInt(value);
        result.significand = IntClone(value);
        float_normalize(&result);
        return result;
            Int factor = IntInit();
    
            temp = IntClone(&value->significand);
            factor = float_pow10((u64)value->exponent);
            IntMul(&temp, &temp, &factor);
    
    static SignedInt sint_clone(SignedInt *value) {
        SignedInt clone = {.negative = value->negative, .magnitude = IntClone(&value->magnitude)};
        sint_normalize(&clone);
        return clone;
    
    static void int_mul_u64_in_place(Int *value, u64 factor) {
        Int lhs    = IntClone(value);
        Int rhs    = MISRA_PRIV_IntFromU64(factor);
        Int result = IntInit();
    
    static void int_add_u64_in_place(Int *value, u64 addend) {
        Int lhs    = IntClone(value);
        Int rhs    = MISRA_PRIV_IntFromU64(addend);
        Int result = IntInit();
    }
    
    Int IntClone(Int *value) {
        ValidateInt(value);
        }
    
        Int current   = IntClone(value);
        Str result    = StrInit();
        ValidateInt(value);
    
        Int temp = IntClone(value);
    
        int_add_u64_in_place(&temp, addend);
            }
    
            Int partial = IntClone(a);
            Int next    = IntInit();
        ValidateInt(value);
    
        Int temp = IntClone(value);
    
        int_mul_u64_in_place(&temp, factor);
    
        Int acc      = MISRA_PRIV_IntFromU64(1);
        Int current  = IntClone(base);
    
        while (exponent > 0) {
        }
    
        Int normalized_dividend = IntClone(dividend);
        Int normalized_divisor  = IntClone(divisor);
        Int q                   = IntInit();
    
        Int normalized_dividend = IntClone(dividend);
        Int normalized_divisor  = IntClone(divisor);
        Int q                   = IntInit();
        Int r                   = IntClone(&normalized_dividend);
        Int normalized_divisor  = IntClone(divisor);
        Int q                   = IntInit();
        Int r                   = IntClone(&normalized_dividend);
    
        if (IntCompare(&normalized_dividend, &normalized_divisor) >= 0) {
            for (u64 shift = dividend_bits - divisor_bits + 1; shift > 0; shift--) {
                u64 bit = shift - 1;
                Int shifted = IntClone(&normalized_divisor);
    
                IntShiftLeft(&shifted, bit);
        ValidateInt(b);
    
        Int x = IntClone(a);
        Int y = IntClone(b);
    
        Int x = IntClone(a);
        Int y = IntClone(b);
    
        while (!IntIsZero(&y)) {
        }
        if (degree == 1) {
            Int exact_root = IntClone(value);
            Int zero_rem   = IntInit();
    
                IntDeinit(&best);
                best = IntClone(&mid);
                IntAdd(&next, &mid, &one);
                IntDeinit(&low);
    
        Int aa = IntInit();
        Int nn = IntClone(n);
        int result = 1;
        Int acc      = MISRA_PRIV_IntFromU64(1);
        Int base_mod = IntInit();
        Int exp      = IntClone(exponent);
    
        IntMod(&acc, &acc, modulus);
        SignedInt t       = sint_init();
        SignedInt new_t   = sint_from_u64(1);
        Int       r       = IntClone(modulus);
        Int       new_r   = IntInit();
        Int       one     = MISRA_PRIV_IntFromU64(1);
    
        IntMod(&reduced, value, modulus);
        new_r = IntClone(&reduced);
    
        while (!IntIsZero(&new_r)) {
        }
        if (MISRA_PRIV_IntModU64(modulus, 4) == 3) {
            Int exponent = IntClone(modulus);
            Int root     = IntInit();
    
        {
            Int q       = IntClone(modulus);
            Int z       = MISRA_PRIV_IntFromU64(2);
            Int c       = IntInit();
            IntPowMod(&t, &a, &q, modulus);
    
            exponent = IntClone(&q);
            MISRA_PRIV_IntAddU64(&exponent, &exponent, 1);
            IntShiftRight(&exponent, 1);
    
            while (MISRA_PRIV_IntCompareU64(&t, 1) != 0) {
                Int t_power = IntClone(&t);
                u64 i       = 0;
    
                {
                    Int b    = IntClone(&c);
                    Int b_sq = IntInit();
                    Int next = IntInit();
    
        {
            Int d           = IntClone(value);
            Int n_minus_one = IntInit();
            u64 s           = 0;
    
            (void)MISRA_PRIV_IntSubU64(&d, &d, 1);
            n_minus_one = IntClone(&d);
    
            while (IntIsEven(&d)) {
        }
    
        Int candidate = IntClone(value);
    
        MISRA_PRIV_IntAddU64(&candidate, &candidate, 1);
    
    bool test_int_clone(void) {
        WriteFmt("Testing IntClone\n");
    
        Int original = IntFromBinary("1011");
    
        Int original = IntFromBinary("1011");
        Int clone    = IntClone(&original);
    
        bool result = IntEQ(&clone, &original);
Last updated on