bit-shiftright(number)

koadrobot/bits/bit-shiftright(number)

Shift right the number value. (0 is right, 31 is left) 31 is sign bit.
bit-shiftright(number)
@/bit-shiftright(number)
Shift right the number value. (0 is right, 31 is left) 31 is sign bit.
INnumber
Input number. Interpreted as a signed 32-bit interger
Nnumber
Input number. Interpreted as a signed 32-bit interger
bit-shiftright(number)
IN
OUT
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);
}