Class: Numeric

Inherits:
Object
  • Object
show all
Defined in:
lib/jinni/numeric.rb

Instance Method Summary collapse

Instance Method Details

#bitsObject

utility method to return the number of bits that the binary representation of the number requires



9
10
11
# File 'lib/jinni/numeric.rb', line 9

def bits
  to_binary.length()
end

#to_binaryObject

utility method to convert a numeric into a binary string.



3
4
5
# File 'lib/jinni/numeric.rb', line 3

def to_binary
  to_s(2)
end