Fixed(N)
Inherits Comparable < Comparable < Comparable < FixedDecimal::Value < Struct < Value < Object
A signed binary fixed-point number stored in an Int128.
The low N bits hold the fraction and the high 128 - N bits hold the
integer part, including the sign, so the value is raw / 2**N. N must
be in 0..127.
price = Fixed(64).new("19.99")
(price * 3).format(decimal: 2) # => "59.97"
Constructors
Builds a value from a sign and a magnitude in units of the least
significant bit. Raises OverflowError when out of range, or when
magnitude is nil (the convention for an intermediate overflow).
Converts, rounding half-to-even. Raises OverflowError if it is out
of range.
Converts a float, rounding half-to-even. Raises ArgumentError for NaN
or infinity and OverflowError if it is out of range.
Converts from any Fixed or UFixed, rounding half-to-even when
fraction bits are lost. Raises OverflowError if it is out of range.
Converts, rounding half-to-even. Raises OverflowError if it is out
of range.
Converts, rounding half-to-even. Raises OverflowError if it is out
of range.
Parses a decimal string such as "-12.375", "1_000.5", ".5" or
"6.02e23", rounding half-to-even to the nearest representable value.
Raises ArgumentError if string is not a valid decimal number and
OverflowError if it is out of range. Leading and trailing whitespace
(ASCII only, as with String#to_i) is ignored when whitespace is true.
Class methods
Instance methods
The value as {negative, magnitude}, with the magnitude in units of the
least significant bit.