[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

decode-float, Infs, signed zeros..

Consider the values
minf = (- inf)

then (decode-float inf)  gives an error.

(/ 1 minf) and (/ 1 inf)  both print as 0.0d0.
But  decode-float shows they have different signs.
The signum function does not notice this, however.

Also note that if the reader encounters  -0.0d0 it produces
a Positive zero, not the same as (* -1 0.0d0).

Probably most people would think signum is the same as ..
(defun newsignum(x)(multiple-value-bind (a b sign) (decode-float x)
but it isn't.

Also,  some other problems:

(/ 1.0d0 0.0d0) seems to inevitably signal an error.  Is there
any way to make it return inf?  Catching it with an errorset is not
particularly informative as to what caused the problem.

(/ 1.0d-200 1.0d200)  gives 0.0d0, no underflow message

 (/ 1.0e-200 1.0e200)  gives ...
Error: This integer is too large to be converted to single float: 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

Is this all viewed as correct in the Common Lisp world?

If so, it makes it hard to do certain things neatly, including
interval arithmetic.