Module: BSON::Decimal128::Builder Private
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Helper module for parsing String, Integer, Float, BigDecimal, and Decimal128 objects into other objects.
Defined Under Namespace
Classes: FromBigDecimal, FromString, ToString
Constant Summary collapse
- INFINITY_MASK =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Infinity mask.
0x7800000000000000
- NAN_MASK =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
NaN mask.
0x7c00000000000000
- SNAN_MASK =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
SNaN mask.
(1 << 57)
- SIGN_BIT_MASK =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Signed bit mask.
(1 << 63)
- TWO_HIGHEST_BITS_SET =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The two highest bits of the 64 high order bits.
(3 << 61)
Instance Method Summary collapse
-
#parts_to_bits(significand, exponent, is_negative) ⇒ Array
private
Convert parts representing a Decimal128 into the corresponding bits.
Instance Method Details
#parts_to_bits(significand, exponent, is_negative) ⇒ Array
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.
Convert parts representing a Decimal128 into the corresponding bits.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/bson/decimal128/builder.rb', line 64 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 |