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);Success
Returns true. *value has been shifted in place.
Failure
Returns false on allocator OOM while growing the significand. *value is left untouched.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Float.c:71:
if (binexp > 0) {
if (!IntShiftLeft(&out->significand, (u64)binexp)) {
return false;
}- In
Int.c:574:
for (u64 i = 0; i < len; i++) {
if (!IntShiftLeft(&result, 8) || !int_add_u64_in_place(&result, bytes[i])) {
IntDeinit(&result);
return IntInit(alloc);- In
Int.c:1003:
}
bool IntShiftLeft(Int *value, u64 positions) {
ValidateInt(value);- In
Int.c:1231:
}
int_normalize(&partial);
if (!IntShiftLeft(&partial, i) || !int_add(&next, &acc, &partial)) {
IntDeinit(&acc);
IntDeinit(&partial);- In
Int.c:1387:
Int shifted = IntInit(IntAllocator(quotient));
if (!int_try_clone_value(&shifted, &normalized_divisor) || !IntShiftLeft(&shifted, bit)) {
IntDeinit(&shifted);
goto cleanup;- In
Int.c:1752:
}
if (!IntShiftLeft(&high, high_shift)) {
IntDeinit(&low);
IntDeinit(&high);- In
Int.Access.c:108:
Int big = IntFrom(1, &alloc.base);
IntShiftLeft(&big, 64);
bool result = IntFitsU64(&small);- In
Int.Access.c:162:
Int zero = IntInit(&alloc.base);
IntShiftLeft(&power, 20);
bool result = IntIsPowerOfTwo(&one); bool error = false;
IntShiftLeft(&value, 64);
bool result = !IntTryToU64(&value, &out);- In
Int.Type.c:57:
result = result && (IntToU64(&clone) == 11);
IntShiftLeft(&original, 1);
result = result && !IntEQ(&clone, &original);- In
Int.Compare.c:70:
Int big = IntFrom(1, &alloc.base);
IntShiftLeft(&big, 80);
bool result = (IntCompare(&value, &same) == 0); Int small = IntFrom(42u, &alloc.base);
Int large = IntFrom(1u, &alloc.base);
IntShiftLeft(&large, 80);
Int decimal = IntFromStr("12345678901234567890", &alloc.base);- In
Int.Math.c:63:
bool test_int_shift_left_grows(void) {
WriteFmt("Testing IntShiftLeft\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Math.c:69:
Int value = IntFrom(3, &alloc.base);
IntShiftLeft(&value, 4);
bool result = IntToU64(&value) == 48;- In
Int.Math.c:963:
bool test_int_shift_left_null(void) {
WriteFmt("Testing IntShiftLeft NULL handling\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Math.c:967:
DefaultAllocator alloc = DefaultAllocatorInit();
IntShiftLeft(NULL, 1);
DefaultAllocatorDeinit(&alloc);
return false;
Last updated on