struct

BSON::Decimal128

Inherits Struct < Value < Object

128-bit decimal floating point.

See: https://github.com/mongodb/specifications/blob/master/source/bson-decimal128/decimal128.rst

Constants

EXPONENT_OFFSET = 6176

Exponent offset.

INFINITY_MASK = 8646911284551352320_u64

Infinity mask.

INFINITY_STRING = "Infinity"

String representing an Infinity value.

MAX_DIGITS_OF_PRECISION = 34

Maximum digits of precision.

MAX_EXPONENT = 6111

Maximum exponent.

MIN_EXPONENT = -6176

Minimum exponent.

NAN_MASK = 8935141660703064064_u64

NaN mask.

NAN_STRING = "NaN"

String representing a NaN value.

SIGN_BIT_MASK = 1_u64 << 63

Signed bit mask.

SNAN_MASK = 1_u64 << 57

SNaN mask.

TWO_HIGHEST_BITS_SET = 3_u64 << 61

The two highest bits of the 64 high order bits.

Constructors

new(significand : UInt128, exponent : Int32, is_negative : Bool)

Convert parts representing a Decimal128 into the corresponding bits.

Source
new(string : String)
Source
new(bytes : Bytes)
Source
new(big_decimal : BigDecimal)
Source

Instance methods

bytes

BSON byte representation.

Source
high
Source
infinity?
Source
nan?
Source
negative?
Source
to_big_d
Source
to_canonical_extjson(builder : JSON::Builder)

Serialize to a canonical extended json representation.

Source
to_io(io : IO, format : IO::ByteFormat = IO::ByteFormat::LittleEndian) : Nil

Write BSON byte representation directly to an IO.

Source
to_json(builder : JSON::Builder)
Source
to_s(io : IO) : Nil

Same as #inspect(io).

Source

Nested types