From: muraken@... Date: 2020-10-26T03:44:16+00:00 Subject: [ruby-core:100546] [Ruby master Bug#16518] Should we rationalize Rational's numerator automatically? Issue #16518 has been updated by mrkn (Kenta Murata). Status changed from Open to Assigned I'm working on it at https://github.com/ruby/ruby/pull/3702 ---------------------------------------- Bug #16518: Should we rationalize Rational's numerator automatically? https://bugs.ruby-lang.org/issues/16518#change-88173 * Author: st0012 (Stan Lo) * Status: Assigned * Priority: Normal * Assignee: mrkn (Kenta Murata) * ruby -v: 2.6.5 * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- In this [Rails issue](https://github.com/rails/rails/issues/38041) we found that using `BigDecimal` as a `Rational`'s numerator can have inconsistent behaviors when the denominator gets bigger. For example: ``` > 1 == BigDecimal(1) => true > Rational(1, 1) == Rational(BigDecimal(1), 1) => true > Rational(1, 6) == Rational(BigDecimal(1), 6) => true > Rational(1, 60) == Rational(BigDecimal(1), 60) => false ``` So my question is, is this behavior expected? If it's not expected, do we have a plan to fix it? If it is, does it make sense to manually rationalize the numerator before passing it into the `Rational` call, in order to get a consistent result? -- https://bugs.ruby-lang.org/ Unsubscribe: