Skip to content

IntShiftLeft

IntShiftLeft

Description

Shift an integer left by the given number of bit positions.

Parameters

Name Direction Description
value in Integer to modify
positions in Number of zero bits to append on the right

Usage example (from documentation)

  IntShiftLeft(&value, 8);

Usage example (Cross-references)

Usage examples (Cross-references)
    
        for (u64 i = 0; i < len; i++) {
            IntShiftLeft(&result, 8);
            int_add_u64_in_place(&result, bytes[i]);
        }
    }
    
    void IntShiftLeft(Int *value, u64 positions) {
        ValidateInt(value);
    
            int_normalize(&partial);
            IntShiftLeft(&partial, i);
            IntAdd(&next, &acc, &partial);
                Int shifted = IntClone(&normalized_divisor);
    
                IntShiftLeft(&shifted, bit);
    
                if (IntGE(&r, &shifted)) {
        }
    
        IntShiftLeft(&high, high_shift);
    
        while (IntLE(&low, &high)) {
    
        Int value = IntFrom(1);
        IntShiftLeft(&value, 64);
        IntToU64(&value);
        Int big   = IntFrom(1);
    
        IntShiftLeft(&big, 80);
    
        bool result = (IntCompare(&value, &same) == 0);
        Int big   = IntFrom(1);
    
        IntShiftLeft(&big, 64);
    
        bool result = IntFitsU64(&small);
        Int zero  = IntInit();
    
        IntShiftLeft(&power, 20);
    
        bool result = IntIsPowerOfTwo(&one);
    
    bool test_int_shift_left_grows(void) {
        WriteFmt("Testing IntShiftLeft\n");
    
        Int value = IntFrom(3);
        Int value = IntFrom(3);
    
        IntShiftLeft(&value, 4);
    
        bool result = IntToU64(&value) == 48;
    
    bool test_int_shift_left_null(void) {
        WriteFmt("Testing IntShiftLeft NULL handling\n");
    
        IntShiftLeft(NULL, 1);
        WriteFmt("Testing IntShiftLeft NULL handling\n");
    
        IntShiftLeft(NULL, 1);
        return false;
    }
        result      = result && (IntToU64(&clone) == 11);
    
        IntShiftLeft(&original, 1);
    
        result = result && !IntEQ(&clone, &original);
Last updated on