2

I've recently stumbled into an interesting Mysql query:

SELECT ~0; results: 18446744073709551615

Which is the max value of a bigint unsigned. What does the tilde operator do in this case?

6

It selects the logical negation of 0 and returns it in the implicitly converted datatype. Rather than selecting 8 bytes containing all 0's, it selects 8 bytes containing all 1's, returning the maximum possible unsigned value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.