SoftBank.Cldr.Money.to_integer_exp
You're seeing just the function
to_integer_exp
, go back to SoftBank.Cldr.Money module for more information.
Returns a tuple comprising the currency code, integer amount, exponent and remainder
Some services require submission of money items as an integer with an implied exponent that is appropriate to the currency.
Rather than return only the integer, Money.to_integer_exp
returns the currency code, integer, exponent and remainder.
The remainder is included because to return an integer
money with an implied exponent the Money
has to be rounded
potentially leaving a remainder.
Arguments
money
is anyMoney.t
struct returned byCldr.Currency.new/2
Notes
- Since the returned integer is expected to have the implied fractional
digits the
Money
needs to be rounded which is what this function does.
Example
iex> m = SoftBank.Cldr.Money.new(:USD, "200.012356")
#Money<:USD, 200.012356>
iex> SoftBank.Cldr.Money.to_integer_exp(m)
{:USD, 20001, -2, Money.new(:USD, "0.002356")}
iex> m = SoftBank.Cldr.Money.new(:USD, "200.00")
#Money<:USD, 200.00>
iex> SoftBank.Cldr.Money.to_integer_exp(m)
{:USD, 20000, -2, Money.new(:USD, "0.00")}