Why does the expression conv('9000084e703720f9', 16, 10) ^ conv('801A93A5A18A773F', 16, 10)
produce wrong result?
In a step by step explanation:
SELECT conv('9000084e703720f9', 16, 10);
Result: 10376302674444755193
SELECT conv('801A93A5A18A773F', 16, 10);
Result: 9230852725838346047
SELECT 10376302674444755193 ^ 9230852725838346047;
Result: 1160411291139790790
But by this query:
SELECT conv('9000084e703720f9', 16, 10) ^ conv('801A93A5A18A773F', 16, 10)
Result: 0
I don't understand why does this return zero?
Best Answer
The problem is that some long string failed to fit into a
BIGINT UNSIGNED
.On the other hand, consider avoiding going through decimal:
8.0 can handle bit operations longer than 64 bits, but perhaps not in this context.