Issue #12958 has been updated by Shyouhei Urabe.


Jerome Cornet wrote:
> Unfortunately there are many instances where money math requires floating point calculation, like taxes for example (discounts are also another source of float-related money math)

I would like to disagree.

It is true that money moth tends to require decimal calculation.  However I have never seen an example where "floating point" calculation is mandatory.

Am I making myself understood?  I am distinguishing Floats and BigDecimals.  We did not change how a BigDecimal rounds.  Money related calculations should use that class instead.  Not Float.  Using Float for money is in fact toxic; for instance you can't express $0.1 using Float.

> Most jurisdictions that charge sales taxes specify rounding up by law: here are 2 US law texts, http://www.tax.ohio.gov/sales_and_use/information_releases/st200505.aspx, http://www.tax.ohio.gov/sales_and_use/information_releases/st200505.aspx, I live in Canada and it's the same http://www.gst-tax.com/GST/Accounting_for_GST.htm. In the UK, it can be both up or down, but in retail it's rounded up as well https://www.gov.uk/government/publications/vat-notice-700-the-vat-guide/vat-notice-700-the-vat-guide#calculation-of-vat-at-retailers

They are all examples of decimal calculations, not floating points.

Also, as I reported in Feature #12953, there do exist a case where round-half-down is requested by a government.  That doesn't mean we don't need round-half-up mode but at least it shows that the mode is not the only thing we need.

> Banker's rounding is actually a poorly named rounding method, as it is only used outside the financial industry. It has the nice property for statistical analysis that it has no bias over the entire numbers space; it's better named as Gaussian rounding.

(I have no strong opinion over how it should be called.  I just pointed the status quo.)

> There are many companies in the financial industry that use ruby, making a change like this is actually a bigger deal than just breaking rails views.

I would like to believe that no serious money calculation is done using Floats.  We have provided BigDecimal for a long time for that purpose.  Even when someone use Float for some reason, I can hardly believe they do so without careful tests.

----------------------------------------
Bug #12958: Breaking change in how `#round` works
https://bugs.ruby-lang.org/issues/12958#change-61801

* Author: Rafael Fran├ža
* Status: Assigned
* Priority: Normal
* Assignee: Kenta Murata
* ruby -v: 
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
We noticed in the Rails test suite that there is a breaking change in how `#round` works between 2.3 and 2.4

https://github.com/rails/rails/pull/27091

Is that desirable?

I think it is may cause a lot of problem if the behavior of `#round` without any arguments changes between a minor version.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>