Reputation: 293
I'm trying to convert some PHP code into MySQL code. Here's what happens:
In PHP: I'm trying to use bitwise not on a number and this is the result I get
var_dump(~(17998320)); Result: -17998321
The result in PHP is exactly what I need.
In MySQL: When I try to do the same here I get a completely different answer.
select ~(17998320); Result: 18446744073691553295
I guess it is something regarding BIGINT. How can I replicate the behaviour I see on PHP into MySQL?
Upvotes: 3
Views: 208
Reputation: 293
I figured out what the problem was!
It's giving me the value in 2's compliment form. So you can get the right value by manually getting into it.
select -1 * (~((~(17998320)) - 1))
Thanks anyways for all the help :)
Upvotes: 2