Hello Benoit,

I think your question is related to 
https://bugs.ruby-lang.org/issues/12005, which is ongoing (slowly). 
Sooner or later, it will be more difficult (or impossible) to 
distinguish Fixnum and Bignum in Ruby-lang, and your question/request 
will resolve itself.

Regards,   Martin.

On 2016/04/26 00:09, Benoit Daloze wrote:
> Hello ruby-core!
>
> I was just wondering why in MRI, Bignum#coerce(1)[0] returns a Bignum.
>
> Is it to strictly satisfy the `coerce` protocol of returning two object of
> the same class?
> As far as I know, all other places in the code base return a Fixnum for
> computations that fit in its range, and Bignum#coerce seems the only
> exception.
>
> I have been experimenting with disallowing Bignum with values in the Fixnum
> range in another implementation and so far it seems to cause no
> incompatibility,
> because core numeric operations already handle Bignum directly anyway and
> Fixnum/Bignum are mostly implementation detail for the regular Ruby user.
>
> So, is there a particular reason why Bignum#coerce allows to create Bignum
> in Fixnum range?


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