Module: Diameter::Internals::UInt24
- Defined in:
- lib/diameter/u24.rb
Overview
Methods for handling 24-bit unsigned integers, used for length and Command-Codes but not representable by String#unpack or Array#pack.
Class Method Summary collapse
-
.from_u8_and_u16(eightb, sixteenb) ⇒ Fixnum
private
Generates an unsigned integer from two other unsigned integers (one representing the top 8 bits, one representing the bottom 16 bits).
-
.to_u8_and_u16(twentyfourb) ⇒ [Fixnum, Fixnum]
private
Converts an unsigned integer to two other unsigned integers (one representing the top 8 bits, one representing the bottom 16 bits).
Class Method Details
.from_u8_and_u16(eightb, sixteenb) ⇒ Fixnum
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Generates an unsigned integer from two other unsigned integers (one representing the top 8 bits, one representing the bottom 16 bits).
17 18 19 |
# File 'lib/diameter/u24.rb', line 17 def self.from_u8_and_u16(eightb, sixteenb) (eightb << 16) + sixteenb end |
.to_u8_and_u16(twentyfourb) ⇒ [Fixnum, Fixnum]
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts an unsigned integer to two other unsigned integers (one representing the top 8 bits, one representing the bottom 16 bits).
29 30 31 32 33 |
# File 'lib/diameter/u24.rb', line 29 def self.to_u8_and_u16(twentyfourb) top_eight = twentyfourb >> 16 bottom_sixteen = twentyfourb - (top_eight << 16) [top_eight, bottom_sixteen] end |