
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.
- compare
-
Compare based on decimal value, scale is not considered for equality (unlike equals).
- decrement
-
Decimal decrement()
Decrement by one. Shortcut is --a or a--.
- div
-
Divide this by b. Shortcut is a/b.
- equals
-
Return true if same decimal with same scale.
- 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.
- hash
-
override Int hash()
Return platform specific hashcode.
- increment
-
Decimal increment()
Increment by one. Shortcut is ++a or a++.
-
new make()
Private constructor.
- max
-
Return the larger of this and the specified Decimal values.
- min
-
Return the smaller of this and the specified Decimal values.
- minus
-
Subtract b from this. Shortcut is a-b.
- mod
-
Return remainder of this divided by b. Shortcut is a%b.
- mult
-
Multiply this with b. Shortcut is a*b.
- negate
-
Decimal negate()
Negative of this. Shortcut is -a.
- plus
-
Add this with b. Shortcut is a+b.
- toDecimal
-
override Decimal toDecimal()
Return this.
- toFloat
-
override Float toFloat()
Convert to 64-bit Float - precision may be lost.
- 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.
- toStr
-
override Str toStr()
Get string representation.