On Tue, Mar 04, 2003 at 06:16:03AM +0900, ghost-no-spam / cotse.net wrote: > > I don't think so. Why don't you just write your own? > > > I may have to have to, but regrettably, math is not my strongest point. > > > What's the format of your input? > > > Standard IP addy, "127.0.0.1". I know what I am looking for can be > accompished with the hton() function in C, (converts host to network byte > order). Hmm, that doesn't do any decimal conversion, just byte ordering. Are you thinking of the C functions inet_aton and inet_ntoa which convert between strings and struct in_addr? In Ruby, the socket functions take the string representation directly, so it's not normally necessary to convert: e.g. require 'socket' t = TCPSocket.new('127.0.0.1', 23) # connect to my telnet port If you really want it as a 4-byte integer then you can convert easily, but beware that IP addrs are likely to be represented as Bignum rather than Fixnum because the size of Fixnum is 31 bits: class Socket def Socket.aton(a) res = 0 a.split(/\./).each { |byte| res<<=8; res|=byte.to_i } res end end ip = '206.27.238.1' puts Socket.aton(ip) #>> 3457936897 printf "%08X\n", Socket.aton(ip) #>> CE1BEE01 Is that what you were looking for? Regards, Brian.