Module: ReadBitsAtOffset
- Defined in:
- lib/innodb/util/read_bits_at_offset.rb
Instance Method Summary collapse
-
#read_bits_at_offset(data, bits, offset) ⇒ Object
Read a given number of bits from an integer at a specific bit offset.
Instance Method Details
#read_bits_at_offset(data, bits, offset) ⇒ Object
Read a given number of bits from an integer at a specific bit offset. The value returned is 0-based so does not need further shifting or adjustment.
6 7 8 |
# File 'lib/innodb/util/read_bits_at_offset.rb', line 6 def read_bits_at_offset(data, bits, offset) ((data & (((1 << bits) - 1) << offset)) >> offset) end |