chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] u8vector to numbers bignum


From: chi
Subject: Re: [Chicken-users] u8vector to numbers bignum
Date: Thu, 28 May 2015 20:02:54 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

On 05/28/2015 12:55 PM, Kon Lovett wrote:
> The integer result range extends to that of the limit parameter. Ex:

Yeah sorry, I didn't see that the first time, my bad.
(random-integer large-bignum) would produce a large bignum just fine. Problem
solved!

But did you take a look at the (random-large-integer) module in -numbers? What
they do is multiply a bignum by a bignum of its digit size (max of a fixnum),
then add random to the new empty digit, and then iterate. I don't want to
prematurely optimize or anything, but that's a REALLY slow way to build up a
sequence of digits in a bignum. Both the guarantee of the multiple being
digit-aligned, and the knowledge of how many digits beforehand, are completely
lost with that method, which has to assume the multiple could be anything, and
can't pre-allocate anything.

A u8vector->number or perhaps set-bignum-digit! function could build the
resulting bignum much faster, if the numbers module supported anything like 
that.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]