Money.from_float-exclamation-mark
You're seeing just the function
from_float-exclamation-mark
, go back to Money module for more information.
Specs
from_float!(currency_code(), float(), Keyword.t()) :: t() | no_return()
Returns a %Money{} struct from a currency code and a float amount, or raises an exception if the currency code is invalid.
See Money.from_float/2
for further information.
Note that Money
cannot detect lack of precision or rounding errors
introduced upstream. This function therefore should be used with
great care and its use should be considered potentially harmful.
Arguments
currency_code
is an ISO4217 three-character upcased binary or atomamount
is a floatoptions
is a keyword list of options passed toMoney.new/3
. The default is[]
.
Examples
iex> Money.from_float!(:USD, 1.234)
#Money<:USD, 1.234>
Money.from_float!(:USD, 1.234567890987654)
#=> ** (Money.InvalidAmountError) The precision of the float 1.234567890987654 is greater than 15 which could lead to unexpected results. Reduce the precision or call Money.new/2 with a Decimal or String amount
(ex_money) lib/money.ex:293: Money.from_float!/2