diff options
author | Mike Mackintosh <m@zyp.io> | 2015-03-22 22:32:33 -0400 |
---|---|---|
committer | Mike Mackintosh <m@zyp.io> | 2015-03-22 22:32:33 -0400 |
commit | 09bde2a5ef66884ab63f8649a15514840c03dd83 (patch) | |
tree | 38ad2e128b89efc30bb3f3d91df691a00356a022 /lib | |
parent | f562a7f7a032b381cdc8b897ec50ed220bcc9452 (diff) | |
download | ipaddress-09bde2a5ef66884ab63f8649a15514840c03dd83.tar.gz |
added bugfix/40 fix with test
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ipaddress/ipv4.rb | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/ipaddress/ipv4.rb b/lib/ipaddress/ipv4.rb index 6437810..fc2976a 100644 --- a/lib/ipaddress/ipv4.rb +++ b/lib/ipaddress/ipv4.rb @@ -1026,12 +1026,9 @@ module IPAddress; # private + # Tweaked to remove the #upto(32) def newprefix(num) - num.upto(32) do |i| - if (a = Math::log2(i).to_i) == Math::log2(i) - return @prefix + a - end - end + return @prefix + (Math::log2(num).to_i) end def sum_first_found(arr) |