On 9/5/2013 10:24 AM, Robert Dodier wrote:
> On 2013-09-05, Raymond Toy <toy.raymond at gmail.com> wrote:
>
>>>>>>> "Camm" == Camm Maguire <camm at maguirefamily.org> writes:
>> Camm> forwarded 707596 maxima at math.utexas.edu thanks
>>
>> Camm> Sanjoy Mahajan <sanjoy at olin.edu> writes:
>>
>> >> Package: maxima Version: 5.30.0-4 Severity: normal
>> >>
>> >> Here's a transcript:
>> >>
>> >> $ maxima
>> >>
>> >> Maxima 5.30.0 http://maxima.sourceforge.net using Lisp GNU
>> >> Common Lisp (GCL) GCL 2.6.7 (a.k.a. GCL) Distributed under the
>> >> GNU Public License. See the file COPYING. Dedicated to the
>> >> memory of William Schelter. The function bug_report() provides
>> >> bug reporting information.
>> >> (%i1) 1000!^0.01;
>> >> (%o1)
>> >> i.nfE+142498684
>>
>> I think this is really an issue with gcl, not maxima. With cmucl and
>> ccl, maxima complains that 1000! is too big to fit in a double-float.
>> It looks as if gcl just converts that to double-float infinity.
The traditional way around such issues has been to define a number of macros
which are selectively expanded depending on the particular common lisp
implementation.
Maybe what we need are a bunch like
(defmacro nanp(x) ...)
(defmacro infinityp(x) ...)
(defmacro coerce_to_float(x) ;;; if x is too big, make inf, do
something reasonable for complex or non-number
...)
I think there are a bunch that can be identified by looking at the
particulars
of some implementation.
I notice that Allegro CL has some constants like *negative-infinity-single*
SBCL has a bunch of features.
dunno about the new GCL. haven't tried it.
While we are looking at this, (or maybe, iF we are looking at this),
consider the
borderline cases where we have inf, minf, infinity as symbols with
properties, and
within the subtype of floats, we have essentially inf, minf. (no
"unsigned infinity"
is available in IEEE754 floats.
Also, in IEEE754 floats there is a -0.0, which has no representation as
a rational
in common lisp, ordinarily. For some uses it would be better if
there would be -0, +0, and unsigned 0. (The inverses of minf, inf,
and infinity!)
Oh, while we are looking at floats, it would be nice to actually have
available
(with_floats_rounding direction &rest)
direction being up, down, tozero, nearest, awayfromzero ...
and a bunch of other stuff like trapping on inexact,
over/underflow/zerodivide.
SBCL may have defined a framework for all this.
I put a bunch of these in a lisp for the now-defunct HP Prism
workstation architecture.
> Well, the larger problem is that nonnumerical floats (inf, nan) don't
> exist in CL. So at best we can patch up Maxima with implementation-
> specific code.
>
> In the case of GCL, at least for formatting numbers for display, I
> suppose we can test for equality of numbers to +/- inf and go from
> there. (There is only one IEEE 754 +inf and one -inf, unlike nan,
> for which there are a lot. However, nans have the useful property
> that nan != nan so they are easy to detect.)
>
> I have to say that the complaint about 1000! too big to fit in a float
> seems less helpful. Why not just make it inf? (If such numbers are
> allowed at all.) Why should exp(1000e0) => inf while float(1000!) =>
> error?
>
> best
>
> Robert Dodier
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima