Open dmasciotra opened 2 weeks ago
proposal: Allow for an option to pass the number of precision to be used
Money.decimal_precision = 8
# or as a block
Money.decimal_precision(8) do
money = Money.new(0.12345678, "USD")
money.to_s #=> "0.12345678"
money.format #=> "0.12"
end
by default the decimal precision is set by the currency
Description
There are some use cases where we would like to have an object contain both the currency and an amount, but not have the library auto round for us based on currency settings. An example could be to represent the value of something to a more precise decimal than the currency supports, for purposes of bulk purchases. A more concrete example could be to set the price of something as $0.057 USD so that when we have 100 of the item, the total cost would be $5.70 USD.
It should be noted arithmetic and logical operations should use this raw value as well.