[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to detect division by zero?
From: |
Roland Orre |
Subject: |
Re: how to detect division by zero? |
Date: |
Tue, 20 Jan 2004 16:40:00 +0100 |
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))
/Roland