[#97536] [Ruby master Bug#16694] JIT vs hardened GCC with PCH — v.ondruch@...
Issue #16694 has been reported by vo.x (Vit Ondruch).
11 messages
2020/03/18
[ruby-core:97522] [Ruby master Bug#12780] BigDecimal#round returns different types depending on argument
From:
matz@...
Date:
2020-03-16 08:29:35 UTC
List:
ruby-core #97522
Issue #12780 has been updated by matz (Yukihiro Matsumoto).
`#round` with the argument less than 1 (`n < 1`) should return `Integer` value.
Matz.
----------------------------------------
Bug #12780: BigDecimal#round returns different types depending on argument
https://bugs.ruby-lang.org/issues/12780#change-84676
* Author: Gat (Dawid Janczak)
* Status: Assigned
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* ruby -v: ruby 2.4.0dev (2016-09-21 trunk 56199) [x86_64-linux]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
BigDecimal#round returns Integer when no arguments are given and BigDecimal otherwise. I would have assumed the result to always be BigDecimal.
BigDecimal.new('12.34').round # => 12 (Integer)
BigDecimal.new('12.34').round(0) # => 12 (BigDecimal)
Attached is a patch with possible fix.
I found a similar issue to this one (https://bugs.ruby-lang.org/issues/2662), but it's in Japanese. If this should be rejected as well could someone provide an explanation in English please? Also in that case documentation should be changed as it clearly states that the result should be BigDecimal: "Round to the nearest integer (by default), returning the result as a BigDecimal."
---Files--------------------------------
bigdecimal_round.diff (969 Bytes)
--
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>