Re: BIGNUM memory and questions

[email protected] ("John M. Gamble") Tue, 27 Nov 2001 17:18:31 -0600 (CST)
Newsgroups perl.perl6.internals.bignum
Message-ID <[email protected]>
On Tue, 27 Nov 2001, Tels wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> 
> Moin,
> 
> On 27-Nov-01 Uri Guttman tried to scribble about:
> >   T> Next question: Why BCD? Do you think this is better, or do you
> >   T> know? (E.g.  why was that decision made. I am asking because there
> >   T> are differences and I want to make sure that the decision is done
> >   T> on research, not on "Uh, we thought it would be better" ;)
> > 
> > bcd is more accurate which is a prime reason. 
> 
> This is untrue. Neither binary nor BCD are more or less accurare. Otherwise
> Math::BigInt lib => 'Pari' would not work 100% as Math::BigInt;
> 

The BCD form is handling fractional parts too, hence the accuracy comment. 

I personally am taking a great interest in this, which is why i volunteered
to help.  About a decade ago, i wrote a VLI package in C++ (which no longer
compiles in current C++ packages, alas), so i know that these things can
be done in multiple ways.  I don't think we have to worry about backwards
compatibility as long as we keep the interface simple - strings, integers,
and reals to internal format, and back again.

> 
> > it will allow for easier conversions to/from strings. 
> 
> This is true. But it will make for very slow multiplications and things
> like 2 ** something. (I bet you know that ;)

Not necessarily.  There are tricks out there for BCD math too.  I admit
you won't get the instant bit set with the '<<' and '>>' operators (question:
are those operators part of the spec?), but 'natural' multiplication
shouldn't be too much slower.  Remember, we're dealing with reals also.

> 
> It will be _MUCH_ slower for some cases. Heh, want some benchmarks? ;)
> 

We'll have to benchmark anyway.  Come on, we can't make speed claims in 
advance of the the code's existance!  It's apples and oranges anyway, 
since BigInt doesn't do fractions.

> 
> > everyone. and get the current tarball at stemsystems.com/bignum.tar.gz
> 
> Will check it out later.

Good!

[remaining comments snipped].

	-john
"I always have a quotation for everything - it saves original thinking."
	Have His Carcase, by Dorothy L. Sayers