I would say that if a piece of code dealing with money uses floats then it's wrong. It's simply the wrong datatype for the job. It can be used for scientific and engineering computations where the amounts we're dealing with are always uncertain. This isn't the case for monetary calculations though.
I would say: if your code is dealing with money and uses floats then it's wrong. I can see at least three representations for money two of which you've already mentioned (BigDecimal and Rational). Personally, I prefer to use integers and count cents. For example, I'd write $123.45 as 123_45. Using Rational or BigDecimal can be problematic when dealing with external systems. For example, I saw a system that issued payment requests in sub-cent precision. The result was that the payment provider rounded these numbers and things didn't add up in the database because the actual payments differed from the requested ones. To sum up, the problems I see are the following: 1. number_to_currency expects a type with fractional part. I can't just pass it 123_45 (= 12345) and expect it to output $123.45. 2. NumberToCurrencyConverter explicitly uses floats <https://github.com/rails/rails/blob/492576e77bbaf8040758ad58854f535d528cc96e/activesupport/lib/active_support/number_helper/number_to_currency_converter.rb#L12> and rounding <https://github.com/rails/rails/blob/492576e77bbaf8040758ad58854f535d528cc96e/activesupport/lib/active_support/number_helper/number_to_currency_converter.rb#L17>. I think they should be replaced with something equivalent to number.divmod(100) (where the precision, 100 in this example, could be configurable). I realize the implications for backward compatibility. I'm just talking about the ideal future code of this helper. 3. The docs for number_to_currency use floats. I think it's irrelevant that literals are seldom used. Storing these values in a database field doesn't change my point - floats aren't the right representation for money. Best regards Greg Navis ᐧ -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at https://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.