Thoughout our app we use number_to_currency(value, :precision => 2)
. However, we now have a requirement whereby the value may need displaying to three or more decimal places, e.g.
0.01 => "0.01"
10 => "10.00"
0.005 => "0.005"
In our current implementation, the third example renders as:
0.005 => "0.01"
What's the best approach for me to take here? Can number_to_currency
be made to work for me? If not, how do I determine how many decimal places a given floating point value should be displayed to? sprintf("%g", value)
comes close, but I can't figure out how to make it always honour a minimum of 2dp.