A decimal floating point number. This class provides support for fixed and arbitrary precision numbers. Values are immutable and represented as unscaled * 10^(-scale). Methods without an explicit Rounding parameter use unlimitedPrecision (unless documented otherwise) except for plus(), minus(), times(), divided() and power() whose implicit rounding is subject to the rounding specified in implicitlyRounded().

no type hierarchy

no subtypes hierarchy

Attributes
floatSource Codeshared formal Float float

The number, represented as a Float. If the magnitude of this number is too large the result will be infinity or -infinity. If the result is finite, precision may still be lost.

hashSource Codeshared formal Integer hash

The hash value of this Decimal. Due to the definition of equals() trailing zeros do not contribute to the hash calculation so 1 and 1.0 have the same `hash.

Refines Object.hash
implementationSource Codeshared formal Object? implementation

The platform-specific implementation object, if any. This is provided for interoperation with the runtime platform.

integerSource Codeshared formal Integer integer

The number, represented as an Integer. If the number is too big to fit in an Integer then an Integer corresponding to the lower order bits is returned.

precisionSource Codeshared formal Integer precision

The precision of this decimal. This is the number of digits in the unscaled value.

See also scale
scaleSource Codeshared formal Integer scale

The scale of this decimal. This is the number of digits to the right of the decimal point (for a positive scale) or the power of ten by which the unscaled value is multiplied (for a negative scale).

See also unscaled
unscaledSource Codeshared formal Whole unscaled

The unscaled value of this Decimal.

See also scale
wholeSource Codeshared formal Whole whole

The number, represented as a Whole, after truncation of any fractional part.

See also Whole
Inherited Attributes
Attributes inherited from: Object
Attributes inherited from: Invertible<Other>
Attributes inherited from: Number<Other>
Methods
dividedSource Codeshared formal Decimal divided(Decimal other)

The quotient obtained by dividing this Decimal by the given Decimal. Unless invoked within implicitlyRounded() the preferred scale of the result is the difference between this Decimal's scale and the given Decimal's scale; it may be larger if necessary; an exception is thrown if the result would have a nonterminating decimal representation.

dividedAndRemainderSource Codeshared formal DividedWithRemainder dividedAndRemainder(Decimal other, Rounding? rounding = null)

A pair containing the same results as calling dividedTruncated() and remainderRounded() with the given arguments, except the division is only performed once.

Parameters:
  • rounding = null
Throws
dividedRoundedSource Codeshared formal Decimal dividedRounded(Decimal other, Rounding? rounding = null)

The quotient obtained by dividing this Decimal by the given Decimal with the given rounding.

Parameters:
  • rounding = null
See also divided()
dividedTruncatedSource Codeshared formal Decimal dividedTruncated(Decimal other, Rounding? rounding = null)

The integer part of the quotient obtained by dividing this Decimal by the given Decimal and truncating the result. The scale of the result is the difference of the scales of the operands.

Parameters:
  • rounding = null
Throws
  • Exception

    The integer part of the quotient requires more than the given precision.

  • Exception

    The given divisor is zero

equalsSource Codeshared formal Boolean equals(Object that)

Determine whether two instances have equal value.equals() considers 1 and 1.0 to be the same, strictlyEquals() considers them to be different.

minusSource Codeshared formal Decimal minus(Decimal other)

The difference between this Decimal and the given Decimal. Unless invoked within implicitlyRounded() the scale of the result is the greater of the scales of the operands.

minusRoundedSource Codeshared formal Decimal minusRounded(Decimal other, Rounding? rounding = null)

The difference between this Decimal and the given Decimal with the given rounding.

Parameters:
  • rounding = null
See also minus()
plusSource Codeshared formal Decimal plus(Decimal other)

The sum of this Decimal and the given Decimal. Unless invoked within implicitlyRounded() the scale of the result is the greater of the scales of the operands.

See also plusRounded()
plusRoundedSource Codeshared formal Decimal plusRounded(Decimal other, Rounding? rounding = null)

The sum of this Decimal and the given Decimal with the given rounding.

Parameters:
  • rounding = null
See also plus()
powerSource Codeshared formal Decimal power(Integer other)

The result of raising this number to the given power. Unless invoked within implicitlyRounded() the result is computed to unlimited precision and negative powers are not supported.

Throws
  • Exception

    The exponent has a non-zero fractional part

  • Exception

    The exponent is too large or too small

  • Exception

    The exponent was negative when attempting to compute a result to unlimited precision

powerRoundedSource Codeshared formal Decimal powerRounded(Integer other, Rounding? rounding = null)

The result of raising this number to the given power with the given rounding. Fractional powers are not supported.

Parameters:
  • rounding = null
See also power()
remainderRoundedSource Codeshared formal Decimal remainderRounded(Decimal other, Rounding? rounding = null)

The Decimal remainder after the division of this Decimal by the given Decimal, that is:

`this - this.dividedTruncated(other, rounding) * other

This is not equivalent to the % operator (Decimal does not satisfy Integral), and the result may be negative.

Parameters:
  • rounding = null
Throws
  • Exception

    The integer part of the quotient requires more than the given precision.

  • Exception

    The given divisor is zero

roundSource Codeshared formal Decimal round(Rounding rounding)

This value rounded according to the given context.

strictlyEqualsSource Codeshared formal Boolean strictlyEquals(Decimal that)

Determine whether two instances have equal value and scale. strictlyEquals() considers 1 and 1.0 to be different, equals() considers them to be the same.

See also equals()
timesSource Codeshared formal Decimal times(Decimal other)

The product of this Decimal and the given Decimal. Unless invoked within implicitlyRounded() the scale of the result is the sum of the scales of the operands.

timesRoundedSource Codeshared formal Decimal timesRounded(Decimal other, Rounding? rounding = null)

The product of this Decimal and the given Decimal with the given rounding.

Parameters:
  • rounding = null
See also times()
Inherited Methods
Methods inherited from: Comparable<Other>
Methods inherited from: Exponentiable<This,Other>
Methods inherited from: Invertible<Other>
Methods inherited from: Number<Other>
Methods inherited from: Numeric<Other>
Methods inherited from: Summable<Other>