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