changing floating point number input.. (was realroots...)



I think that IEEE 754 may be too restrictive. 854, which is a
radix-independent version is around too, but that doesn't meet our needs
much better.

The MPFR people do not do IEEE 754, but they say that they "take the good
ideas" from it.


 We could adopt MPFR wholesale for all floats, and have
special routines that take these numbers and map them down to double-floats
when speed counts, e.g. crunching numbers for linear algebra. This is
usually very reasonable, since the conversion is "linear time" and most of
the other stuff is much slower.  This kind of transformation is used by
Mathematica and perhaps Maple too.


Maxima bigfloats were designed to be IEEE 754 compatible in a number of
respects, such as round-to-nearest-even.  But bigfloats never overflow or
underflow. They don't have denormalized numbers. Not so for IEEE 754. I
think MPFR probably CAN overflow, but only at some super-horrendous
exponent.

(IEEE 754 is being revised right now, but I doubt that the changes will make
the standard dramatically better or worse from our perspective.)

RJF

Here's a change to make the output of infinities and NaNs work in
Allegro+Maxima... Someone who knows GCL etc should be able to make the
corresponding changes with conditionalizations for GCL, CLISP, etc.

in the file nforma.lisp

add this..


#+allegro
(defun replace-bad-guy(x);; This uses the mistake that infinities can be
compared equal
  (cond ((excl::nan-p x) '|$NaN|)  ;;-- or could be a parameter??
	((or (equal x  #.excl::*infinity-double*)
	     (equal x  #.excl::*infinity-single*))
	 '$oo);; looks like infinity oo  -- or could be a parameter??
	((or (equal x  #.excl::*negative-infinity-double*)
	     (equal x  #.excl::*negative-infinity-single*))
	 '$-oo)
	(t x)));; not really a bad guy ?? what happened?


;; alter this program..

(defmfun nformat (form)
  (cond ((atom form)
	 (cond ((numberp form)
		;; could be a number or an infinity or Nan
		(cond
		 #+allegro
		 ((excl::exceptional-floating-point-number-p form);; change
8/27/06 RJF
		  (replace-bad-guy form))
		    
		 ((minusp form)
		  (list '(mminus) (minus form)))
		 (t form)))
	       ;;atom, not number.		    
	       ((eq t form) (if in-p t '$true))

;;;etc no change for the rest of the function