Fantom

 

const final class

sys::Decimal

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

@simple

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

Slots

absSource

Decimal abs()

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

compareSource

override Int compare(Obj obj)

Overrides sys::Obj.compare

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

decrementSource

Decimal decrement()

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

defValSource

static Decimal defVal

Default value is 0.

divSource

Decimal div(Decimal b)

Divide this by b. Shortcut is a/b.

equalsSource

override Bool equals(Obj? obj)

Overrides sys::Obj.equals

Return true if same decimal with same scale.

fromStrSource

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.

hashSource

override Int hash()

Overrides sys::Obj.hash

Return platform specific hashcode.

incrementSource

Decimal increment()

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

maxSource

Decimal max(Decimal that)

Return the larger of this and the specified Decimal values.

minSource

Decimal min(Decimal that)

Return the smaller of this and the specified Decimal values.

minusSource

Decimal minus(Decimal b)

Subtract b from this. Shortcut is a-b.

modSource

Decimal mod(Decimal b)

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

multSource

Decimal mult(Decimal b)

Multiply this with b. Shortcut is a*b.

negateSource

Decimal negate()

Negative of this. Shortcut is -a.

plusSource

Decimal plus(Decimal b)

Add this with b. Shortcut is a+b.

toCodeSource

Str toCode()

Get this Decimal as a Fantom code literal.

toLocaleSource

Str toLocale(Str? pattern := null)

Format this decimal number for the current locale. If pattern is null, then the locale's default pattern is used. See Float.toLocale for pattern language and examples.

toStrSource

override Str toStr()

Overrides sys::Obj.toStr

Get string representation.