[Maxima] bfloat hangs computer

Raymond Toy raymond.toy at ericsson.com
Thu Mar 19 10:42:55 CDT 2009


Edwin Woollett wrote:
> On Wed, Mar 18, 2009  Robert Dodier wrote:
> --------------------------------------------------
>> 1b<foo> attempts to call (EXPT 10 <foo>) so when <foo>
>> is a large integer (positive or negative), it is trying to compute
>>  a very large integer or 1/(very large integer). I'm guessing that
>>  when Maxima appears to hang, it is actually running EXPT and
>>  just taking a very long time.
> -----------------------------------
> In fact Maxima has no problem returning exp(-10^n) for n equal
> to 8 or larger. The problem is when Maxima is asked to
> add (or subtract)  the number 1 to that tiny number
> using bfloat( 1 + e) where e has been defined as exp(-bfloat(10^j) )
> for j = 8 or larger.
Here is the fix that was checked in.  Just place this in some file and
load it.  (Or compile and load it.)  Then you can continue your work. 
Doesn't fix the issue about 1b<foo> but does fix the bfloat addition issue.

Ray

(in-package "MAXIMA")
(defun haipart (x n)
  (let ((x (abs x)))
    (if (< n 0)
    ;; If the desired number of bits is larger than the actual
    ;; number, just return the number.  (Prevents gratuitously
    ;; generating a huge bignum if n is very large, as can happen
    ;; with bigfloats.)
    (if (< (integer-length x) (- n))
        x
        (logand x (1- (ash 1 (- n)))))
    (ash x (min (- n (integer-length x)) 0)))))


More information about the Maxima mailing list