Download

Bit operators. Blueprint

Hi

Is it possible to add Blueprint bitshift and bittest operators (>>, <<, bittest) in future Unreal Engine versions? Sometimes very need (especialy while FX asset code development).

There are bit operators like & and ^, just search for them.
Bitshifting is multiply(<<) or divide(>>) by 2

To expand for people who might be confused, if you got a binary number like 110101, and you multiply it by 2… what you end up getting is this (From the right-most bit):

1 * 2 is 2, so 10 in binary, i.e. 0 and carry the 1. (0)
0 * 2 is 0, add the 1 we carried and we get 1 (10)
1 * 2 is 2, same as above, result is 0 and 1 in the carry (010)
0 * 2 is 0, add the carry, we get 1 (1010)
1 * 2 is 1, i.e. 0 and carry 1 (01010)
1 * 2 is 2, now we have 0, but also 1 in the carry, so it’ll be 1 and another 1 in the carry (101010)
Lastly, we have the 1 we carried from the last operation, giving us the final result of 1101010, which is 110101 shifted 1 bit to the left.

And easier way to wrap your head around it is if you think of it in terms of “bit-shifting” numbers in base 10, i.e. “normal” numbers. If you multiply a number by 10, you are essentially shifting all of the digits 1 space to the left. Dividing it shifts it 1 space to the right. The same applies to binary, where the 2 is effectively a “10”.