Performs logical right-shift of `IN` by `N` bits.
shift-right
@/shift-right
Performs logical right-shift of `IN` by `N` bits.
#pragma XOD dirtieness disable
node {
void evaluate(Context ctx) {
int32_t x = (int32_t)getValue<input_IN>(ctx);
int32_t n = (int32_t)getValue<input_N>(ctx);
int32_t b = 0;
if (n < 0) {
b = 0;
} else if (n > 31) {
b = 31;
} else {
b = n;
}
emitValue<output_OUT>(ctx, x >> b);
}
}
IN | N | OUT |
0 | 0 | 0 |
1 | 0 | 1 |
-1 | 0 | -1 |
101 | -52 | 101 |
32.55 | 0 | 32 |
-239523.23 | 0 | -239523 |
1 | 2 | 0 |
128 | 4 | 8 |
-1024 | 3 | -128 |
-1024 | 3.5 | -128 |
1000000000 | 31 | 0 |
1000000000 | 32 | 0 |
1000000000 | 250 | 0 |
-1000000000 | 31 | -1 |
-1000000000 | 32 | -1 |
-1000000000 | 250 | -1 |