detecting lisp overflow



A simple way to test for INF in IEEE floating point is 1/x = 0.  In GCL,
1.0/0.0 gives an error, not an INF, so you need to check for that case, i.e.
(and (/= x 0.0) (= (/ 1.0 x) 0.0)).

             -s

On Sun, Mar 17, 2013 at 3:52 PM, Edwin Woollett <woollett at charter.net>wrote:

> On Mar. 17, 2013, Raymond Toy wrote
>
>    Edwin> If I call adaptive-plot (plot.lisp) appropriately with a
> function like
>    Edwin> exp(x^3) to see what overflow
>    Edwin> causes adaptive-plot to return, I get, for example,
>    Edwin> the lisp list
>
>  What exactly are you trying to achieve?
>>
>> Note that adaptive-float actually expects the function to have been
>> generated by coerce-float-fun, which takes care to handle arithmetic
>> errors and converts them to t.
>>
>
> Thanks for the feedback.
>
> Indeed, I use the line
>
>       (setq fcn (coerce-float-fun fcn `((mlist), (second range))))
>
> in my code, modeled after a simplified version of draw2d,
> which calls adaptive-plot and which wants to inspect the
> "result" list returned by adaptive-plot for either overflow
> or T values for each subregion (of the "plotting" range),
> with the number of subregions  determined by NTICKS,
> as is done in draw2d.
>
> I want to *first* check the returned list "result" for any function
> overflows
> which gcl indicates with the list element #<1.#INF00e+000> which
> evidently is not directly accessible to current maxima functions
> ordinarily used, since using neither (numberp #<1.#INF00e+000>)
> nor (float-nan-p #<1.#INF00e+000>) nor (float-inf-p #<1.#INF00e+000>)
> nor ($floatnump  #<1.#INF00e+000>)  avoids lisp errors.
>
> So far, based on the responses from you and Richard Fateman, it appears
> that I will have to convert the list elements to strings and work with
> strings to detect an overflow return from adaptive-plot.
>
> Ted Woollett
>
>
> ______________________________**_________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/**mailman/listinfo/maxima<http://www.math.utexas.edu/mailman/listinfo/maxima>;
>