Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bitwise shift in mysql

How can I make a bitwise shift in MySQL? Is there any specific instruction or operator? If not, how to simulate it optimally?

like image 761
Ivan Avatar asked Dec 13 '22 11:12

Ivan


2 Answers

Have a look at the bitwise operators in MySQL first: http://dev.mysql.com/doc/refman/5.0/en/bit-functions.html

Then you have left shift:

http://dev.mysql.com/doc/refman/5.0/en/bit-functions.html#operator_left-shift

And right shift:

http://dev.mysql.com/doc/refman/5.0/en/bit-functions.html#operator_right-shift

like image 122
rzetterberg Avatar answered Dec 29 '22 17:12

rzetterberg


To use a bitwise shift in MySQL, you can use << or >> for left shift or right shift respectively.

like image 40
Dirk Avatar answered Dec 29 '22 17:12

Dirk