IntShiftRight
Description
Shift an integer right by the given number of bit positions.
Parameters
| Name | Direction | Description |
|---|---|---|
value |
in | Integer to modify |
positions |
in | Number of low bits to discard |
Usage example (from documentation)
IntShiftRight(&value, 1);Success
Returns true. *value has been shifted in place.
Failure
Returns false on allocator OOM while trimming the significand. *value is left untouched.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Int.c:1031:
}
bool IntShiftRight(Int *value, u64 positions) {
ValidateInt(value);- In
Int.c:1766:
int cmp = 0;
if (!int_add(&sum, &low, &high) || !IntShiftRight(&sum, 1)) {
IntDeinit(&sum);
IntDeinit(&mid);- In
Int.c:1972:
u64 n_mod_8 = 0;
if (!IntShiftRight(&aa, 1)) {
IntDeinit(&aa);
IntDeinit(&nn);- In
Int.c:2263:
}
if (!IntShiftRight(&exp, 1)) {
IntDeinit(&acc);
IntDeinit(&base_mod);- In
Int.c:2480:
Int root = IntInit(IntAllocator(result));
if (!IntTryClone(&exponent, modulus) || !int_add_u64(&exponent, &exponent, 1) || !IntShiftRight(&exponent, 2) ||
!int_pow_mod(&root, &a, &exponent, modulus)) {
IntDeinit(&exponent);- In
Int.c:2514:
}
while (IntIsEven(&q)) {
if (!IntShiftRight(&q, 1)) {
IntDeinit(&q);
IntDeinit(&z);- In
Int.c:2568:
}
if (!IntTryClone(&exponent, &q) || !int_add_u64(&exponent, &exponent, 1) || !IntShiftRight(&exponent, 1) ||
!int_pow_mod(&r, &a, &exponent, modulus)) {
IntDeinit(&q);- In
Int.c:2786:
while (IntIsEven(&d)) {
if (!IntShiftRight(&d, 1)) {
IntDeinit(&d);
IntDeinit(&n_minus_one);- In
Int.Math.c:80:
bool test_int_shift_right_shrinks(void) {
WriteFmt("Testing IntShiftRight\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Int.Math.c:86:
Int value = IntFromBinary("110000", &alloc.base);
IntShiftRight(&value, 4);
bool result = IntToU64(&value) == 3;
Last updated on