Class: Integer
- Inherits:
-
Object
- Object
- Integer
- Defined in:
- lib/integer.rb
Instance Method Summary collapse
Instance Method Details
#negate ⇒ Object
7 8 9 |
# File 'lib/integer.rb', line 7 def negate self + 1 & 1 end |
#to_array_of_bits(width) ⇒ Object
3 4 5 |
# File 'lib/integer.rb', line 3 def to_array_of_bits(width) ("%0#{width}b" % self).split(//).map(&:to_i) end |