Return a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object:
this < that => <0
this == that => 0
this > that => >0
This method may also be accessed via the <
<=
<=>
>=
and >
shortcut operators. If not overridden the default
implementation compares the toStr
representations. Also see docLang.
Examples:
3.compare(8) => -1
8.compare(3) => 1
8.compare(8) => 0
3 <=> 8 => -1 // shortcut for 3.compare(8)
Compare this object to the specified for equality. This
method may be accessed via the == and != shortcut operators.
If not overridden the default implementation compares for
reference equality using the === operator. If this method
is overridden, then hash() must also be overridden such that
any two objects which return true for equals() must return
the same value for hash(). This method must accept null
and
return false.
Return a unique hashcode for this object. If a class overrides hash() then it must ensure if equals() returns true for any two objects then they have same hash code.
Get an immutable representation of this instance or throw NotImmutableErr if this object cannot be represented as an immutable:
Return a string representation of this object.
Trap a dynamic call for handling. Dynamic calls are invoked with the -> shortcut operator:
a->x a.trap("x", null)
a->x() a.trap("x", null)
a->x = b a.trap("x", [b])
a->x(b) a.trap("x", [b])
a->x(b, c) a.trap("x", [b, c])
The default implementation provided by Obj attempts to use reflection. If name maps to a method, it is invoked with the specified arguments. If name maps to a field and args.size is zero, get the field. If name maps to a field and args.size is one, set the field and return args[0]. Otherwise throw UnknownSlotErr.
This method called whenever an it-block is applied to an
object. The default implementation calls the function with this
,
and then returns this
.
Static
absReturn the absolute value of this decimal. If this value is positive then return this, otherwise return the negation.
Static
compareStatic
decrementDecrement by one. Shortcut is --a or a--.
Static
defDefault value is 0.
Static
divDivide this by b. Shortcut is a/b.
Static
divDivide this by b. Shortcut is a/b.
Static
divDivide this by b. Shortcut is a/b.
Static
echoWrite x.toStr
to standard output followed by newline. If x
is null then print "null". If no argument is provided then
print an empty line.
Optional
x: JsObjStatic
equalsStatic
fromParse a Str into a Decimal. If invalid format and checked is false return null, otherwise throw ParseErr.
Optional
checked: booleanStatic
hashReturn platform specific hashcode.
Static
incrementIncrement by one. Shortcut is ++a or a++.
Static
localeGet the current locale's decimal separator. For example in the the US this is a dot.
Static
localeGet the current locale's separator for grouping thousands together. For example in the US this is a comma.
Static
localeGet the current locale's minus sign used to represent a negative number.
Static
localeGet the current locale's string representation for not-a-number.
Static
localeGet the current locale's string representation for negative infinity.
Static
localeGet the current locale's symbol for the percent sign.
Static
localeGet the current locale's string representation for positive infinity.
Static
maxReturn the larger of this and the specified Decimal values.
Static
minReturn the smaller of this and the specified Decimal values.
Static
minusSubtract b from this. Shortcut is a-b.
Static
minusSubtract b from this. Shortcut is a-b.
Static
minusSubtract b from this. Shortcut is a-b.
Static
modReturn remainder of this divided by b. Shortcut is a%b.
Static
modReturn remainder of this divided by b. Shortcut is a%b.
Static
modReturn remainder of this divided by b. Shortcut is a%b.
Static
multMultiply this with b. Shortcut is a*b.
Static
multMultiply this with b. Shortcut is a*b.
Static
multMultiply this with b. Shortcut is a*b.
Static
negateNegative of this. Shortcut is -a.
Static
plusAdd this with b. Shortcut is a+b.
Static
plusAdd this with b. Shortcut is a+b.
Static
plusAdd this with b. Shortcut is a+b.
Static
toGet this Decimal as a Fantom code literal.
Static
toConvert this number to a Decimal.
Static
toConvert this number to a Float.
Static
toConvert this number to an Int.
Static
toFormat 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.
Optional
pattern: stringOptional
locale: LocaleStatic
toGet string representation.
Decimal is used to represent a decimal floating point more precisely than a Float. Decimal is the preferred numeric type for financial applications.