logo

const final class

sys::Decimal

sys::Obj
  sys::Num
    sys::Decimal

Decimal is used to represent a decimal floating point more precisely than a Float. Decimal is the preferred numeric type for financial applications.

Slots

abs

Decimal abs()

Return the absolute value of this decimal. If this value is positive then return this, otherwise return the negation.

Source

compare

override Int compare(Obj obj)

Compare based on decimal value, scale is not considered for equality (unlike equals).

Source

decrement

Decimal decrement()

Decrement by one. Shortcut is --a or a--.

Source

div

Decimal div(Decimal b)

Divide this by b. Shortcut is a/b.

Source

equals

override Bool equals(Obj obj)

Return true if same decimal with same scale.

Source

fromStr

static Decimal fromStr(Str s, Bool checked := true)

Parse a Str into a Decimal. If invalid format and checked is false return null, otherwise throw ParseErr.

Source

hash

override Int hash()

Return platform specific hashcode.

Source

increment

Decimal increment()

Increment by one. Shortcut is ++a or a++.

Source

max

Decimal max(Decimal that)

Return the larger of this and the specified Decimal values.

Source

min

Decimal min(Decimal that)

Return the smaller of this and the specified Decimal values.

Source

minus

Decimal minus(Decimal b)

Subtract b from this. Shortcut is a-b.

Source

mod

Decimal mod(Decimal b)

Return remainder of this divided by b. Shortcut is a%b.

Source

mult

Decimal mult(Decimal b)

Multiply this with b. Shortcut is a*b.

Source

negate

Decimal negate()

Negative of this. Shortcut is -a.

Source

plus

Decimal plus(Decimal b)

Add this with b. Shortcut is a+b.

Source

toDecimal

override Decimal toDecimal()

Return this.

Source

toFloat

override Float toFloat()

Convert to 64-bit Float - precision may be lost.

Source

toInt

override Int toInt()

Convert to 64-bit Int, and fractional part if truncated. If too big for an Int, then only the low-order 64 bits are returned.

Source

toStr

override Str toStr()

Get string representation.

Source