Re: Failure in bitwise operations moving from 5.2.x to 5.3.x
| From: | Andy McKenzie | Date: | Tue, 15 Mar 2011 15:50:42 +0000 |
| Subject: | Re: Failure in bitwise operations moving from 5.2.x to 5.3.x | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-311863@lists.php.net to get a copy of this message | ||
> Now: I did a little more looking around this morning, and it looks
> like I may well run into problems here given that I'm moving from a
> 32-bit architecture to a 64-bit architecture. Bitwise math is still
> fairly obscure to me, so it's likely that I'm overlooking something
> obvious, but maybe instead of asking "How do I fix this?" I should be
> asking "What would the right way to do this have been?" As I think I
> said before, I didn't actually write most of this code, I inherited
> it, and as long as the input and output of the class remain the same,
> I don't actually care how the work is done.
>
>
> If anyone has any useful input here, I'd appreciate it!
>
> -Alex
>
As it turns out, the most important lesson here is: "Don't trust what
anyone tells you." The old server is 64-bit. The new server is
32-bit. Once I stopped to check that myself, it all became clear.
For the archives, here's what happened.
Everything worked fine until I ran bindec() on the binary netmask; at
that point it returned a float rather than an int, as it it used to.
Therefore, when I ran ip2long on the result, it choked, and returned
bool(false). Which isn't really useful when you're trying to produce
a human-readable netmask, when you get right down to it.
I still don't have a solution that will work on a 32-bit server, but
now that I know what's going on, I should be able to either find
something that will work, or get things moved to a 64-bit machine.
-Alex