ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:100546] [Ruby master Bug#16518] Should we rationalize Rational's numerator automatically?
       [not found] <redmine.issue-16518.20200119070258.11268@ruby-lang.org>
@ 2020-10-26  3:44 ` muraken
  0 siblings, 0 replies; only message in thread
From: muraken @ 2020-10-26  3:44 UTC (permalink / raw)
  To: ruby-core

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/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-10-26  3:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-16518.20200119070258.11268@ruby-lang.org>
2020-10-26  3:44 ` [ruby-core:100546] [Ruby master Bug#16518] Should we rationalize Rational's numerator automatically? muraken

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).