Performs logical left-shift of `IN` by `N` bits.
shift-left
@/shift-left
Performs logical left-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 |
| 115 | -2 | 115 |
| 32.55 | 0 | 32 |
| -239523.23 | 0 | -239523 |
| 1 | 2 | 4 |
| 128 | 4 | 2048 |
| -1024 | 3 | -8192 |
| -1024 | 3.5 | -8192 |
| 1 | 31 | -2147483648 |
| 1 | 254 | -2147483648 |
| 1 | 260 | -2147483648 |
| 1000000000 | 31 | 0 |
| 1000000000 | 250 | 0 |
| -1000000000 | 31 | 0 |
| -1000000000 | 250 | 0 |