From: "t3ch.dude" Date: 2008-12-04T07:09:23+09:00 Subject: Re: ipaddr and invalid ipv4 addresses On Dec 3, 7:03 am, Martin DeMello wrote: > What's going on here? > > irb(main):002:0> require 'ipaddr' > => true > > irb(main):003:0> ip = IPAddr.new('192.168.1.1024') > => # The snippet above is pretty easy to understand if you convert the ip to a single integer, then convert back to hex... irb(main):003:0> ip1=((192*256+168)*256+1)*256+1024 => 3232236800 irb(main):004:0> ip1.to_s(16).scan(/../).map{|v| v.to_i(16)}.join ( ".") => "192.168.5.0"