Fast conversion to bfloat?



Am Dienstag, den 08.12.2009, 09:55 -0500 schrieb Raymond Toy:
> Bug 2910001 lists an issue with slow conversion of bfloat inputs.  Yes,
> for bfloats with 1 million digits, the conversion from the input form to
> a bfloat is slow.
> 
> This is caused by how maxima does the conversion.  The example in the
> report is 3.4b5000000.  Maxima essentially compute 34/10*10^5000000. 
> This computation is pretty slow.  The conversion to bfloat of that
> rational number is quite fast.
> 
> I like this method because we get exactly one rounding operation and the
> result is a close as possible to the actual input.
> 
> The only other way I can think of is to compute the result as
> bfloat(34/10)*bfloat(10)^5000000.  This is fast, but we get two rounding
> operations (34/10) and the multiplication, and then whatever rounding we
> get from computing 10^5000000.  Perhaps this is acceptable.
> 
> Opinions?

On my notebook with CLISP 2.44 I get an overflow for the given example.

(%i10) 3.4b5000000
Maxima encountered a Lisp error:

overflow during multiplication of large numbers

Automatically continuing.
To enable the Lisp debugger set *debugger-hook* to nil.


But this works:

(%i15) bfloat(34/10)*bfloat(10)^5000000;
Evaluation took 0.0040 seconds (0.0025 elapsed) using 6.352 KB.
(%o15)                     3.400000000006349b5000000


For the following number it works too:

(%i16) 3.4b600000;
Evaluation took 0.0000 seconds (0.0002 elapsed) using 88 bytes.
(%o16)                            3.4b600000

For the last values their seems to be no problem with the evaluation
time. I do not know the dependencies of the bigfloat conversion on the
Lisp implementation. But this dependencies might cause some extra
difficulties to get a general solution for converting very big numbers.

Dieter Kaiser