Trying a lot and just failing..
$x = 76561198005785475;
I want to this number, turn into this:
$y = 45519747;
This is too long to write into a comment, so I'll post it here instead.
@Kolink has the right answer; what you want is that operation. However, note that because your $x
is too big to be stored in an int
format anyway, it'll be held as a float
in 32-bit computers, and float
s suffer from precision loss. My pet theory on why you get 45519744 instead of the right answer is that your 32-bit computer lost the precision on the last digits. To see this in action, try this here:
$x = 76561198005785475;
echo (int)$x;
That site uses a 32-bit server, and it returns 45519744. This demonstrates the precision loss.
On the other hand, if you go here and run:
$x = 76561198005785475;
$y = $x & 0xffffff;
You get the right answer, because that site is 64-bit.
If you want to do the operation on a 32-bit machine (as you evidently do), I suggest you use gmp_and from the PHP GMP extension. Unfortunately I couldn't test to see if it works - I'll leave that to you.