[107162] in North American Network Operators' Group

home help back first fref pref prev next nref lref last post

Re: interger to I P address

daemon@ATHENA.MIT.EDU (Scott Doty)
Wed Aug 27 13:21:28 2008

Date: Wed, 27 Aug 2008 10:21:23 -0700
From: Scott Doty <scott@sonic.net>
To: nanog@nanog.org
In-Reply-To: <20080827101756.K71371-100000@apollo.gti.net>
Errors-To: nanog-bounces@nanog.org

On Wed, Aug 27, 2008 at 10:25:10AM -0400, Shadow wrote:
> 
> Robert D. Scott wrote:
> > The harder way:
> >
> > Decimal: 1089055123
> > Hex (dashes inserted at octals): 40-E9-A9-93
> > Decimal (of each octet): 64-233-169-147
> > IP Address: 64.233.169.147
> 
> 
> The "this could take all day" way :
> 
> (in bc with scale=0 for integer portions only)
> 
> 1089055123/(2^24)%(2^8)
> 64
> 1089055123/(2^16)%(2^8)
> 233
> 1089055123/(2^8)%(2^8)
> 169
> 1089055123/(2^0)%(2^8)
> 147
> 
> (Note: 2^0=1 & x/1=x so last line could reduce to 1089055123%(2^8).)

$ bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'. 
obase=256
1089055123
 064 233 169 147

 -Scott


home help back first fref pref prev next nref lref last post