Re: Proposal: New Bignum

From: "Evan Webb" <evan@...>
Date: 2004-04-06 07:50:07 UTC
List: ruby-core #2750
Hi matz and friends,

See comments below...

> -----Original Message-----
> From: Yukihiro Matsumoto [mailto:matz@ruby-lang.org]
> Sent: Tuesday, April 06, 2004 12:18 AM
> To: ruby-core@ruby-lang.org
> Subject: Re: Proposal: New Bignum
> 
> Hi,
> 
> In message "Proposal: New Bignum"
>     on 04/04/06, "Evan Webb" <evan@fallingsnow.net> writes:
> 
> |And thus I propose that we integrate MBignum into the ruby core as
> Bignum,
> |replacing the current implementation. This will give ruby more builtin
> |mathematical power and allow other core developers the ability to
> |concentrate on other issues. Licensing wise, there is no problem. Tom St.
> |Denis, the author of libtommath, has released libtommath as public
> domain. I
> |believe that we should of course give him credit if and when we integrate
> |his work.
> 
> I'm not sure whether replacing current bignum is a good idea.  The
> integer values in Ruby go back and forth between Fixnum and Bignum
> according to its value range, which might not be a desired behavior
> for cryptogram calculation etc.

I've thought about that myself. In terms of cryptographic calculations, if
an MBignum is going to interact with an Integer, it coerces it into a
MBignum. Also, MBignum's don't down convert themselves to Integers. 
IE:
	m2 / m2 = p # p == 0
	0.class # MBignum

This helps maintain that you are always working with a MBignum's where you
expect. You can also force an Integer into an MBignum using Integer#to_m.

In other words, I see that if coerce is used well, internal conversions
shouldn't be a problem.

> There are several options:
> 
>   * replace the current bignum, adding new features to Fixnum as
>     well.

Hm. Do you mean integrating MBignum AND adding stuff to Fixnum? What about
using MBignum for all numbers?

>   * bundle MBignum extension along with standard distribution.

I've had numerous people ask me not to do this, especially with the current
multiple libraries problem.

> 
>   * let it be standalone extension.

I guess that would be the current situation.

> 
>   * or something else.

I'm all ears.


> 
> 
> 							matz.

Evan M. Webb // evan@fallingsnow.net


In This Thread