From: Todd Benson Date: 2008-05-06T23:54:00+09:00 Subject: Re: Conversion mask in hex to bit mask On Tue, May 6, 2008 at 6:29 AM, Marcin Tyman wrote: > Hi, > The issue is: how to convert hex mask to bit mask? For instance: > > I have 0xffff0000 -> it can be represent by 255.255.0.0 or by string > of bits - 16 > > My question is how to convert such hexes to bit mask (the 16 in above > example) > > > Thanks in advance, > Have a nice day irb(main):001:0> 0xffff0000.to_s(2) =~ /0*$/ => 16 Untested for other masks. hth, Todd