Please copy me on responses. TIA.
I am trying to do some IP address arithmetic using php, but am running into problems
because the biggest number that php can handle is 32 bits signed. No good for IP
addresses.
Try the following:
echo 2473473024 & 127; // gives 0 - correct
echo 2473473025 & 127; // gives 0 - incorrect
echo 28288 & 127; // gives 0 - correct
echo 28289 & 127; // gives 1 - correct
What happens is that numbers that are bigger than 31 bits are automagically converted
to double, which does not allow binary operations (no error though, just wrong
results!!!). Is there anyway to make the number unsigned or a long int as in C? Else,
how do I do binary arithmetic for IP addresses?
This is using 4.04p1.
--
Richard Ellerbrock
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]