On 11/10/05, David Budd <[EMAIL PROTECTED]> wrote:
> > Raniak Robert is right.
> > I did mistake in formulation. Right one is
> > (256*256*256*A)+(256*256*B)+(256*C)+D
>
> I've always done ((A*256+B)*256+C)*256+D
> Slightly more efficient
is not. They both have three multiplications and three adds,
after the constants have been folded. You could do it with
bitshifting instead of math if you want, and it you're
afraid of endianness problems with
pack('C4',split /\./,$ip)
(A<<24)|(B<<16)|(C<<8)|D
There was a perl6 proposal once to add the math concept of interval
to regular expression language, but it didn't get much traction.
--
David L Nicol
A room without books is perfect for watching television
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs