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