float bigfloat complex numbers



The original motivation was to have a function like
Mathmatica's N[]. The idea is to convert to float/bfloat
numbers at (almost [*]) every opportunity, ideally making
standard, or at least well defined, choices where
neccessary.

I did write tofloat(), but it is still an experiment. The
conversion of powers was a sticking point. It does this:

Converts to double

(%i1) tofloat(%pi);
(%o1) 3.141592653589793

Ask for 10 digit precision. Converts to double

(%i1) tofloat(%pi,10);
(%o1) 3.141592653589793

Ask for 20 digits. Converts to bfloat

(%i2) tofloat(%pi,20);
(%o2) 3.1415926535897932385b0

Trys to convert to double. Traps lisp error
(or returned INF for gcl) and then converts to bfloat.

(%i3) tofloat(1000!);
(%o3) 4.02387260077094b2567

Mathematica will refuse to promote N[1.0,1000]. One could
add some logic like this to tofloat(). But, Maxima doesn't
have Mathematica's notion of precision. So for Maxima, I
think it is better to allow the promotion and advise caveat
emptor.

For instance, this is useful (it just calls bfloat)
is(tofloat(1.0,100) = tofloat(1,100)) --> true

Here, you should be aware of what you are getting.
is(tofloat(1.1,100) = tofloat(11/10,100)) --> false

Mathematica would give different objects in both
of the preceeding cases. (But, == gives true! )

By the way: tofloat() calls cbfloat(), which is just
bfloat() with the modification for powers.  If I
rename cbfloat to bfloat, I get infinite loops that I have
not been able to track down. I did rename a similar cfloat()
to float() with no problem.  This is why I have no
working patch for bfloat(). Maybe someone else could spot
the problem quickly.

[*] neither Maxima, nor Mathematica convert the 2
     in float(x^2), N[x^2].


--John