[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to detect division by zero?
From: |
John W. Eaton |
Subject: |
Re: how to detect division by zero? |
Date: |
Tue, 20 Jan 2004 10:02:44 -0600 |
On 20-Jan-2004, Roland Orre <address@hidden> wrote:
| On Tue, 2004-01-20 at 15:17, Rouben Rostamian wrote:
| > How does one detect the result of a division by 0.0 in guile?
|
| You could define the values of the not_a_numbers and test with those.
| In guile 1.7 symbols for these values are already predefined, so you
| could use the following definitions to be future compatible. However,
| I just found that (/ 0.0 0.0) can not be tested neither in 1.6 or 1.7.
|
| (define +inf.0 (/ 1.0 0.0))
| (define -inf.0 (/ -1.0 0.0))
| (define +nan.0 (/ 0.0 0.0))
|
| guile-user> (= +inf.0 (/ 100.0 0.0))
| #t
| guile-user> (= -inf.0 (/ -100.0 0.0))
| #t
|
| Of some reason does the followoing return false
| guile-user> (= +nan.0 (/ 0.0 0.0))
NaN values never compare equal. To check for them, you need isnan. I
helped to write a patch for this some time ago. Doesn't guile 1.7 (or
some newer than 1.6 version) have isinf, isnan, and other IEEE
floating point functions and values built in?
jwe