bit-shiftleft(number)

koadrobot/bits/bit-shiftleft(number)

Shift left the number value. (0 is right, 30 is left) 31 is sign bit.
bit-shiftleft(number)
@/bit-shiftleft(number)
Shift left the number value. (0 is right, 30 is left) 31 is sign bit.
INnumber
Input number. Interpreted as a signed 32-bit interger
Nnumber
(0 is right, 31 is left)
bit-shiftleft(number)
OUT
IN
N
OUTnumber
To use the node in your project you should have the koadrobot/bits library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#pragma XOD dirtieness disable

struct State {
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    int32_t x = (int32_t)getValue<input_IN>(ctx);
    int32_t n = (int32_t)getValue<input_N>(ctx);
    n = (n>0) ? ((n<31) ? n : 31) : 0;
    emitValue<output_OUT>(ctx, x << n);
}

Tabular tests

INNOUT
000
101
-10-1
115-2115
32.55032
-239523.230-239523
124
12842048
-10243-8192
-10243.5-8192
131-2147483648
1254-2147483648
1260-2147483648
1000000000310
10000000002500
-1000000000310
-10000000002500