module BSON::Decimal128::Builder
def parts_to_bits(significand, exponent, is_negative)
- Since: - 4.2.0
Returns:
-
(Array)
- Tuple of the low and high bits.
Parameters:
-
is_negative
(true, false
) -- Whether the value is negative. -
exponent
(Integer
) -- The exponent. -
significand
(Integer
) -- The significand.
def parts_to_bits(significand, exponent, is_negative) validate_range!(exponent, significand) exponent = exponent + Decimal128::EXPONENT_OFFSET high = significand >> 64 low = (high << 64) ^ significand if high >> 49 == 1 high = high & 0x7fffffffffff high |= TWO_HIGHEST_BITS_SET high |= (exponent & 0x3fff) << 47 else high |= exponent << 49 end if is_negative high |= SIGN_BIT_MASK end [ low, high ] end