bit manipulation - How to use binary/bitfield literals in a MySQL statement -


select (bin(~'101010101010101')) result; result : '1111111111111111101001000010000111000000110011111000000101001010' 

is true?

i expect see result:

'1111111111111111111111111111111111111111111111111010101010101010'

help me please.

you passing string bitwise operation. these operations defined bigint integers in mysql, might unexpected results.

you should try:

select bin(~0x5555) result 

or:

select bin(~b'101010101010101' ) result 

results in:

'1111111111111111111111111111111111111111111111111010101010101010' 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -