[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: division by 0

**From**: |
Bernard Urban |

**Subject**: |
Re: division by 0 |

**Date**: |
29 Mar 2004 11:09:20 +0200 |

**User-agent**: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 |

Marius Vollmer <address@hidden> writes:
>* Bernard Urban <address@hidden> writes:*
>* *
>* > Debian woody on i386.*
>* >*
>* > $ guile*
>* > guile> (version)*
>* > "1.6.4"*
>* > guile> (/ 0)*
>* > +#.#*
>* > guile> (/ 1.0 0)*
>* > +#.#*
>* > guile> (/ 1 0.0)*
>* > +#.#*
>* > guile>(/ 1 0)*
>* > standard input:3:1: In procedure / in expression (/ 1 0):*
>* > standard input:3:1: Numerical overflow*
>* > ABORT: (numerical-overflow)*
>* >*
>* > Type "(backtrace)" to get more information or "(debug)" to enter the *
>* > debugger.*
>* > guile>*
>* >*
>* > Problem happens in numbers.c, function scm_divide(), where the test *
>* > #line 3274 should not be made.*
>* *
>* The 1.7 series should be handling this more correctly. From NEWS:*
>* *
>* ** There is support for Infinity and NaNs.*
>* *
>* Following PLT Scheme, Guile can now work with infinite numbers, and*
>* 'not-a-numbers'.*
>* *
>* There is new syntax for numbers: "+inf.0" (infinity), "-inf.0"*
>* (negative infinity), "+nan.0" (not-a-number), and "-nan.0" (same as*
>* "+nan.0"). These numbers are inexact and have no exact counterpart.*
>* *
>* Dividing by an inexact zero returns +inf.0 or -inf.0, depending on the*
>* sign of the dividend. The infinities are integers, and they answer #t*
>* for both 'even?' and 'odd?'. The +nan.0 value is not an integer and is*
>* not '=' to itself, but '+nan.0' is 'eqv?' to itself.*
>* *
>* For example*
>* *
>* (/ 1 0.0)*
>* => +inf.0*
>* *
>* (/ 0 0.0)*
>* => +nan.0*
>* *
>* (/ 0)*
>* ERROR: Numerical overflow*
Is (/ 1 x) always equal to (/ x) in 1.7 ?
This is actually my problem. It originates in the fact that hobbit
converts (/ x) to (/ 1 x), and for x = 0, it fails for 1.6.
Why would I want to divide by 0 ? To obtain... nan !
In the interpreter, you can have:
(define nan (- (/ 0) (/ 0)))
For hobbit, you must do:
(define nan (eval '(- (/ 0) (/ 0)) (interaction-environment)))
>* *
>* Two new predicates 'inf?' and 'nan?' can be used to test for the*
>* special values.*
--
Bernard Urban