struct const class std::Decimal
sys::Obj sys::Num std::Decimal
@Serializable { simple=true }
Decimal is used to represent a decimal floating point more precisely than a Float. Decimal is the preferred numeric type for financial applications.
- abs
-
Decimal abs()
Return the absolute value of this decimal. If this value is positive then return this, otherwise return the negation.
- compare
-
virtual override Int compare(Obj obj)
Compare based on decimal value, scale is not considered for equality (unlike
equals
). - decrement
-
Decrement by one. Shortcut is --a or a--.
- defVal
-
const static Decimal defVal
Default value is 0.
- div
-
@Operator
Decimal div(Decimal b)Divide this by b. Shortcut is a/b.
- divFloat
-
@Operator
Decimal divFloat(Float b)Divide this by b. Shortcut is a/b.
- divInt
-
@Operator
Decimal divInt(Int b)Divide this by b. Shortcut is a/b.
- equals
-
virtual override Bool equals(Obj? obj)
Return true if same decimal with same scale.
- fromStr
-
static new 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
-
virtual override Int hash()
Return platform specific hashcode.
- increment
-
Increment by one. Shortcut is ++a or a++.
- max
-
Return the larger of this and the specified Decimal values.
- min
-
Return the smaller of this and the specified Decimal values.
- minus
-
@Operator
Decimal minus(Decimal b)Subtract b from this. Shortcut is a-b.
- minusFloat
-
@Operator
Decimal minusFloat(Float b)Subtract b from this. Shortcut is a-b.
- minusInt
-
@Operator
Decimal minusInt(Int b)Subtract b from this. Shortcut is a-b.
- mod
-
@Operator
Decimal mod(Decimal b)Return remainder of this divided by b. Shortcut is a%b.
- modFloat
-
@Operator
Decimal modFloat(Float b)Return remainder of this divided by b. Shortcut is a%b.
- modInt
-
@Operator
Decimal modInt(Int b)Return remainder of this divided by b. Shortcut is a%b.
- mult
-
@Operator
Decimal mult(Decimal b)Multiply this with b. Shortcut is a*b.
- multFloat
-
@Operator
Decimal multFloat(Float b)Multiply this with b. Shortcut is a*b.
- multInt
-
@Operator
Decimal multInt(Int b)Multiply this with b. Shortcut is a*b.
- negate
-
Negative of this. Shortcut is -a.
- plus
-
@Operator
Decimal plus(Decimal b)Add this with b. Shortcut is a+b.
- plusFloat
-
@Operator
Decimal plusFloat(Float b)Add this with b. Shortcut is a+b.
- plusInt
-
@Operator
Decimal plusInt(Int b)Add this with b. Shortcut is a+b.
- toCode
-
Str toCode()
Get this Decimal as a Fantom code literal.
- toDecimal
- toFloat
-
virtual override Float toFloat()
Convert this number to a Float.
- toInt
-
virtual override Int toInt()
Convert this number to an Int.
- toLocale
-
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.
- toStr
-
virtual override Str toStr()
Get string representation.