Get the Currency
value of this Money
The Currency
value of this Money
Rounds the value of a Money
to a step
value. The rounding behaviour is
defined by the mode
parameter.
Examples:
(USD$1.05).round(1, RoundingMode.UP) => USD$2.00
(USD$1.05).round(1, RoundingMode.DOWN) => USD$1.00
(USD$1.05).round(1, RoundingMode.NEAREST) => USD$1.00
(USD$1.50).round(1, RoundingMode.NEAREST) => USD$2.00
(USD$1.88).round(0.05, RoundingMode.NEAREST) => USD$1.90
(USD$3.50).round(10, RoundingMode.UP) => USD$10.00
The positive step value to round to. The Money
will be
rounded to a multiple of this value.
The rounding mode to use.
A new Money
instance with the rounded value
Create a Money
instance from an amount and currency
The unit amount the Money
should represent (For example, $5.25 USD would have amount 5.25
)
The currency that the Money
should be in (For example, USD would be Currencies.USD
)
A new Money
instance
Generated using TypeDoc
A
Money
represents an amount of money in a given currency.Money
exposes a set of math and comparison operators that can be used to interact with it. The intermediate results of these operations follow f64's behaviour. IfMoney
is included as part of a script's output, then the value is converted to an integer amount of subunits before it is returned from the script.The following operators are supported by this class:
*
/
==
!=
+
-
>
>=
<
<=