want to convert hex to binary which gives answer is more than 64 bits

85 views Asked by At

I want to convert hex to binary

If I use conv function then it gives wrong result if that result contains binary value greater than 64 bits

I want to convert below hex no to binary

hex b3c935bb3667c964db1381db72fd8c897023879b19ab42e937839983cece465d18b719b8a37059ead4152298396f78743aa48245d1d80b899d19bd4e8217c963a187e97d028726c2

if I use conv function it gives result like:

 SELECT CONV('b3c935bb3667c964db1381db72fd8c897023879b19ab42e937839983cece465d18b719b8a37059ead4152298396f78743aa48245d1d80b899d19bd4e8217c963a187e97d028726c2 ',16,2);

output:

1111111111111111111111111111111111111111111111111111111111111111

But I want answer like :

101100111100100100110101101110110011011001100111110010010110010011011011000100111000000111011011011100101111110110001100100010010111000000100011100001111001101100011001101010110100001011101001001101111000001110011001100000111100111011001110010001100101110100011000101101110001100110111000101000110111000001011001111010101101010000010101001000101001100000111001011011110111100001110100001110101010010010000010010001011101000111011000000010111000100110011101000110011011110101001110100000100001011111001001011000111010000110000111111010010111110100000010100001110010011011000010

1

There are 1 answers

0
genesst On

b3c935bb3667c964db1381db72fd8c897023879b19ab42e937839983cece465d18b719b8a37059ead4152298396f78743aa48245d1d80b899d19bd4e8217c963a187e97d028726c2 can't be treated as a hexademical value, it's far more bigger than maximum 64-bit integer value which is equivalent to (7FFFFFFFFFFFFFFF)16.

MySQL gives you correct result of (7FFFFFFFFFFFFFFF)16 = (0111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111)2. Use string to binary conversion instead if you to achive the result you mentioned.