Module: BitTwiddle
- Defined in:
- ext/bit_twiddle/bit_twiddle.c
Class Method Summary collapse
- .add_core_extensions ⇒ Object
-
.arith_rshift16 ⇒ Integer
Arithmetic right-shift of the low 16 bits in
int. -
.arith_rshift32 ⇒ Integer
Arithmetic right-shift of the low 32 bits in
int. -
.arith_rshift64 ⇒ Integer
Arithmetic right-shift of the low 64 bits in
int. -
.arith_rshift8 ⇒ Integer
Arithmetic right-shift of the low 8 bits in
int. -
.bitreverse16 ⇒ Integer
Reverse the low 16 bits in
int. -
.bitreverse32 ⇒ Integer
Reverse the low 32 bits in
int. -
.bitreverse64 ⇒ Integer
Reverse the low 64 bits in
int. -
.bitreverse8 ⇒ Integer
Reverse the low 8 bits in
int. -
.bswap16 ⇒ Integer
Reverse the least-significant and second least-significant bytes of
int. -
.bswap32 ⇒ Integer
Reverse the least-significant 4 bytes of
int. -
.bswap64 ⇒ Integer
Reverse the least-significant 8 bytes of
int. -
.hi_bit ⇒ Integer
Return the index of the highest 1 bit, where the least-significant bit is index 1.
-
.lo_bit ⇒ Integer
Return the index of the lowest 1 bit, where the least-significant bit is index 1.
-
.lrot16 ⇒ Integer
Left-rotation (“circular shift”) of the low 16 bits in
int. -
.lrot32 ⇒ Integer
Left-rotation (“circular shift”) of the low 32 bits in
int. -
.lrot64 ⇒ Integer
Left-rotation (“circular shift”) of the low 64 bits in
int. -
.lrot8 ⇒ Integer
Left-rotation (“circular shift”) of the low 8 bits in
int. -
.lshift16 ⇒ Integer
Left-shift of the low 16 bits in
int. -
.lshift32 ⇒ Integer
Left-shift of the low 32 bits in
int. -
.lshift64 ⇒ Integer
Left-shift of the low 64 bits in
int. -
.lshift8 ⇒ Integer
Left-shift of the low 8 bits in
int. -
.popcount ⇒ Integer
Return the number of 1 bits in
int. -
.rrot16 ⇒ Integer
Right-rotation (“circular shift”) of the low 16 bits in
int. -
.rrot32 ⇒ Integer
Right-rotation (“circular shift”) of the low 32 bits in
int. -
.rrot64 ⇒ Integer
Right-rotation (“circular shift”) of the low 64 bits in
int. -
.rrot8 ⇒ Integer
Right-rotation (“circular shift”) of the low 8 bits in
int. -
.rshift16 ⇒ Integer
Right-shift of the low 16 bits in
int. -
.rshift32 ⇒ Integer
Right-shift of the low 32 bits in
int. -
.rshift64 ⇒ Integer
Arithmetic right-shift of the low 64 bits in
int. -
.rshift8 ⇒ Integer
Right-shift of the low 8 bits in
int.
Class Method Details
.add_core_extensions ⇒ Object
1406 1407 1408 1409 1410 1411 1412 |
# File 'ext/bit_twiddle/bit_twiddle.c', line 1406
static VALUE
bt_add_core_extensions(VALUE self)
{
/* this is so Yardoc can find method definitions */
init_core_extensions();
return Qnil;
}
|
.arith_rshift16 ⇒ Integer
Arithmetic right-shift of the low 16 bits in int.
If bit 16 is a 1, the vacated bit positions will be filled with 1s. Otherwise, they will be filled with 0s. Or, if the shift distance is negative, a left shift will be performed instead, and the vacated bit positions will be filled with 0s.
.arith_rshift32 ⇒ Integer
Arithmetic right-shift of the low 32 bits in int.
If bit 32 is a 1, the vacated bit positions will be filled with 1s. Otherwise, they will be filled with 0s. Or, if the shift distance is negative, a left shift will be performed instead, and the vacated bit positions will be filled with 0s.
.arith_rshift64 ⇒ Integer
Arithmetic right-shift of the low 64 bits in int.
If bit 64 is a 1, the vacated bit positions will be filled with 1s. Otherwise, they will be filled with 0s. Or, if the shift distance is negative, a left shift will be performed instead, and the vacated bit positions will be filled with 0s.
.arith_rshift8 ⇒ Integer
Arithmetic right-shift of the low 8 bits in int.
If bit 8 is a 1, the vacated bit positions will be filled with 1s. Otherwise, they will be filled with 0s. Or, if the shift distance is negative, a left shift will be performed instead, and the vacated bit positions will be filled with 0s.
.bitreverse16 ⇒ Integer
Reverse the low 16 bits in int.
If int is negative, raise RangeError.
.bitreverse32 ⇒ Integer
Reverse the low 32 bits in int.
If int is negative, raise RangeError.
.bitreverse64 ⇒ Integer
Reverse the low 64 bits in int.
If int is negative, raise RangeError.
.bitreverse8 ⇒ Integer
Reverse the low 8 bits in int.
If int is negative, raise RangeError.
.bswap16 ⇒ Integer
Reverse the least-significant and second least-significant bytes of int. If int is negative, raise RangeError.
.bswap32 ⇒ Integer
Reverse the least-significant 4 bytes of int.
Does not reverse bits within each byte. This can be used to swap endianness of a 32-bit integer.
If int is negative, raise RangeError.
.bswap64 ⇒ Integer
Reverse the least-significant 8 bytes of int.
Does not reverse bits within each byte. This can be used to swap endianness of a 64-bit integer.
If int is negative, raise RangeError.
.hi_bit ⇒ Integer
Return the index of the highest 1 bit, where the least-significant bit is index 1. If int is 0, return 0. If int is negative, raise RangeError.
.lo_bit ⇒ Integer
Return the index of the lowest 1 bit, where the least-significant bit is index 1. If this integer is 0, return 0. If int is negative, raise RangeError.
.lrot16 ⇒ Integer
Left-rotation (“circular shift”) of the low 16 bits in int.
If the rotate distance is negative, the bit rotation will be to the right instead.
.lrot32 ⇒ Integer
Left-rotation (“circular shift”) of the low 32 bits in int.
If the rotate distance is negative, the bit rotation will be to the right instead.
.lrot64 ⇒ Integer
Left-rotation (“circular shift”) of the low 64 bits in int.
If the rotate distance is negative, the bit rotation will be to the right instead.
.lrot8 ⇒ Integer
Left-rotation (“circular shift”) of the low 8 bits in int.
If the rotate distance is negative, the bit rotation will be to the right instead.
.lshift16 ⇒ Integer
Left-shift of the low 16 bits in int.
If the shift distance is negative, a right shift will be performed instead. The vacated bit positions will be filled with 0 bits. If shift distance is more than 15 or less than -15, the low 16 bits will all be zeroed.
.lshift32 ⇒ Integer
Left-shift of the low 32 bits in int.
If the shift distance is negative, a right shift will be performed instead. The vacated bit positions will be filled with 0 bits. If shift distance is more than 31 or less than -31, the low 32 bits will all be zeroed.
.lshift64 ⇒ Integer
Left-shift of the low 64 bits in int.
If the shift distance is negative, a right shift will be performed instead. The vacated bit positions will be filled with 0 bits. If shift distance is more than 63 or less than -63, the low 64 bits will all be zeroed.
.lshift8 ⇒ Integer
Left-shift of the low 8 bits in int.
If the shift distance is negative, a right shift will be performed instead. The vacated bit positions will be filled with 0 bits. If shift distance is more than 7 or less than -7, the low 8 bits will all be zeroed.
.popcount ⇒ Integer
Return the number of 1 bits in int. If int is negative, raise RangeError.
.rrot16 ⇒ Integer
Right-rotation (“circular shift”) of the low 16 bits in int.
If the rotate distance is negative, the bit rotation will be to the left instead.
.rrot32 ⇒ Integer
Right-rotation (“circular shift”) of the low 32 bits in int.
If the rotate distance is negative, the bit rotation will be to the left instead.
.rrot64 ⇒ Integer
Right-rotation (“circular shift”) of the low 64 bits in int.
If the rotate distance is negative, the bit rotation will be to the left instead.
.rrot8 ⇒ Integer
Right-rotation (“circular shift”) of the low 8 bits in int.
If the rotate distance is negative, the bit rotation will be to the left instead.
.rshift16 ⇒ Integer
Right-shift of the low 16 bits in int.
If the shift distance is negative, a left shift will be performed instead. The vacated bit positions will be filled with 0 bits. If shift distance is more than 15 or less than -15, the low 16 bits will all be zeroed.
.rshift32 ⇒ Integer
Right-shift of the low 32 bits in int.
If the shift distance is negative, a left shift will be performed instead. The vacated bit positions will be filled with 0 bits. If shift distance is more than 31 or less than -31, the low 32 bits will all be zeroed.
.rshift64 ⇒ Integer
Arithmetic right-shift of the low 64 bits in int.
If bit 64 is a 1, the vacated bit positions will be filled with 1s. Otherwise, they will be filled with 0s. Or, if the shift distance is negative, a left shift will be performed instead, and the vacated bit positions will be filled with 0s.
.rshift8 ⇒ Integer
Right-shift of the low 8 bits in int.
If the shift distance is negative, a left shift will be performed instead. The vacated bit positions will be filled with 0 bits. If shift distance is more than 7 or less than -7, the low 8 bits will all be zeroed.