I think you can get it by shifting the correct number of bits and masking
off the lower 8 bits.

my $x = $b1+$b2+$b3+$b4;
$a4 = $x & 0xFF;
$a3 = ($x>>8) & 0xFF;
$a2 = ($x>>16) & 0xFF;
$a1 = ($x>>24) & 0xFF; 

Good Luck!
Tanton

-----Original Message-----
From: P lerenard
To: [EMAIL PROTECTED]
Sent: 8/23/2001 4:01 PM
Subject: a1.a2.a3.a4 -> integer

Hi,
I can transform an ip a1.a2.a3.a4 to an integer using
b1=a1 << 24
b2=a2 << 16
b3=a3 << 8
int =b1+b2+b3+a4
now I want to do the opposite.
how can I get a1.a2.a3.a4 from this integer?
ok I get a1, but I start to have a headeach to get the rest

Thanks

Pierre


_________________________________________________________________
Get your FREE download of MSN Explorer at
http://explorer.msn.com/intl.asp


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to