[ruby-core:75200] Re: Bignum in Fixnum Range

From: Benoit Daloze <eregontp@...>
Date: 2016-04-26 11:06:15 UTC
List: ruby-core #75200
Thanks Martin, indeed that would resolve it.

I am also wondering the choice in the current implementation
since I guess resolving that issue will take a few releases.

On Tue, Apr 26, 2016 at 12:09 PM, Martin J. D=C3=BCrst <duerst@it.aoyama.ac=
.jp>
wrote:

> 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 an=
d
>> Fixnum/Bignum are mostly implementation detail for the regular Ruby user=
.
>>
>> So, is there a particular reason why Bignum#coerce allows to create Bign=
um
>> in Fixnum range?
>>
>
>
> Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=3Dunsubscrib=
e>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>
>

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

In This Thread

Prev Next