Class: Integer
- Inherits:
-
Object
- Object
- Integer
- Defined in:
- lib/fwt.rb
Instance Method Summary collapse
-
#power_of_2? ⇒ Boolean
Boolean test of whether an Integer is a pure power of two.
Instance Method Details
#power_of_2? ⇒ Boolean
Boolean test of whether an Integer is a pure power of two. This is an O(1) algorithm.
73 74 75 |
# File 'lib/fwt.rb', line 73 def power_of_2? (self.nonzero? & (self-1)) == 0 end |