Project

General

Profile

Actions

Bug #16518

closed

Should we rationalize Rational's numerator automatically?

Added by st0012 (Stan Lo) about 4 years ago. Updated over 3 years ago.

Status:
Closed
Target version:
-
[ruby-core:96942]

Description

In this Rails issue 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?

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0