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
Return the absolute value of this decimal
Compare based on decimal value, scale is not considered for equality (unlike equals)
Decrement by one
Divide this by b
Divide this by b
Divide this by b
Return true if same decimal with same scale
Return platform specific hashcode
Increment by one
Return the larger of this and the specified Decimal values
Return the smaller of this and the specified Decimal values
Subtract b from this
Subtract b from this
Subtract b from this
Return remainder of this divided by b
Return remainder of this divided by b
Return remainder of this divided by b
Multiply this with b
Multiply this with b
Multiply this with b
Negative of this
Add this with b
Add this with b
Add this with b
Get this Decimal as a Fantom code literal
Format this decimal number for the current locale
Get string representation
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 := true)
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 := null, Locale locale := Locale.cur())
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.