I posted the following on the old forun last night. Now I have figuring out case sensitivity problem I was haveing with loging in here. I will repeat myself here in the New forum.
Here we go on an adventure in NAN :)
Fresh Start:
newLISP v6.5.23-win32 Copyright (c) 1993-2002 Lutz Mueller. All rights reserved
> (set '+NAN (sqrt -1))
sqrt: DOMAIN error
+NAN
> (NaN? +NAN)
true
> (set 'X +NAN)
+NAN
> (NaN? X)
true
> (save "loadtest.lsp")
true
LoadTest contains:
(set '+NAN +NAN)
(set 'X +NAN)
Fresh Start:
newLISP v6.5.23-win32 Copyright (c) 1993-2002 Lutz Mueller. All rights reserved.
> (load "test")
true
> (symbols)
(! != % & * + +NAN - / < << <= = > >= >> ? MAIN NaN? X ^ abs ...... | ~)
> +NAN
nil
> (NaN? +NAN)
Value expected in function NaN?
> X
nil
> (NaN? X)
Value expected in function NaN?
>
Edit LoadTest file:
;(set '+NAN +NAN) Don't mess with +NAN !
(set 'X +NAN)
Fresh Start:
newLISP v6.5.23-win32 Copyright (c) 1993-2002 Lutz Mueller. All rights reserved
> (set '+NAN (sqrt -1))
sqrt: DOMAIN error
+NAN
> (NaN? +NAN)
true
> (load "loadtest.lsp")
true
> (NaN? X)
true
>
If +NAN was a constant, then its inference
could be carried between states using (save)(load)
without having to force an seemingly untrapable error to generating one.
> (catch (set '+NAN (sqrt -1)) 'result)
sqrt: DOMAIN error
true
>
How can I generate a +NaN that I can test for with NAN?
without fireing off the error handler ?
Why you ask?
I am using the +NAN as a place holding excluder.
The Current Doc states:
syntax: (NaN? number )
Tests if the result of floating point math operation is a NaN.
Certain floating point operations return a special IEE 754 number
format called a NaN for 'Not a Number'.
example:
(set 'x (sqrt -1) => NaN
(add x 123) => NaN
(> x 0) => nil
(<= x 0) => nil
(= x x) => nil
(NaN? x) => true
Note that all floating point arithmetik operations with a NaN will
yield a NaN. All comparisons with NaN will return nil,
even if comparing NaN to itself.
While we are on the subject of the fact that "Certain floating point operations
return a special IEE 754 number format"
How about Pi ? Having access to the constant for Pi would be great !!!
A test (Pi? number ) would be very nice also. Problem is people trying
(Pi? 3.1416)
Final Note: a (div 1 0) should return a +NAN and not return to the OS !
Thanks, now I feel better :)
Keep up the good work.
Thanks
(bob)
bob@bradlee.org