Unable to get a dot-decimal ip address from a decimal ip address
| From: | dharana at dharana dot net | Date: | Thu, 04 Oct 2001 03:40:17 +0000 |
| Subject: | Unable to get a dot-decimal ip address from a decimal ip address | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-69864@lists.php.net to get a copy of this message | ||
Hi,
decbin() is unable to handle decimal numers greater than 2147483647 and it's a
problem. That's in the docs, ok. The situation is: I have a list of IPs in
decimal format (ex: 3232235524) and I wanted to translate them into dot decimal.
As far as I know the formula is:
[...]by converting the
number to binary, breaking the binary number down into 4 octets and then
converting each octet into a dotted-decimal number.
(got from http://www.montagar.com/~patj/ipmath.txt)
When I try to do this with PHP, I get just 1's because the IPs are greater than
2147483647. Anyone knows a workaround for this?
Thanks in advance.
--
dharana <dharana@dharana.net> Black holes are where
PGP KeyID: 0xC32A724 GOOD is dividing by zero