[Ecls-list] wrong value for (float-sign -0.0)
Gabriel Dos Reis
gdr at cs.tamu.edu
Sun Sep 28 20:07:04 UTC 2008
Raymond Toy <toy.raymond at gmail.com> writes:
| Gabriel Dos Reis wrote:
| > Raymond Toy <toy.raymond at gmail.com> writes:
| >
| > | Gabriel Dos Reis wrote:
| > | > Hi Juanjo,
| > | >
| > | > ECL reports wrong value for the sign of -0.0.
| > | >
| > | > > *features*
| > | > (:LINUX :FORMATTER :IEEE-FLOATING-POINT :RELATIVE-PACKAGE-NAMES :DFFI
| > | > :CLOS-STREAMS :CMU-FORMAT :UNIX :ECL-PDE :DLOPEN :CLOS :BOEHM-GC :ANSI-CL
| > | > :COMMON-LISP :ECL :COMMON :PENTIUM3 :FFI :PREFIXED-API)
| > | > > (float-sign -0.0)
| > | > 0.0
| > | >
| > | >
| > | > The correct value is -1.0.
| > | >
| > | >
| > | Signed zeroes aren't required to be supported.
| >
| > Notice :IEEE-FLOATING-POINT on the *features*.
| What does that mean?
What do you think it would mean? ECL assumes it in all systems, as
far as I can tell from the source code.
| I don't think it's specified anywhere what that
| really means, especially pertaining to signed zeroes. I vaguely
| remember the CLHS saying signed zeroes aren't required.
It is true CLHS does not require signed zeros, but it does require
that in case signed is supported then it must not return garbage answer.
I'm arguing that ECL is already using the native `double', which in
most cases already support signed zeros. C is not the problem here --
see C99 already has it.
| > ECL is using the machine native `double'; there is no point in
| > pretending it does not have signed 0.0.
| >
| > | It looks like ecl
| > | doesn't support signed zeroes. (eql -0.0 0.0) -> T.
| >
| > That equality has to hold no matter whether signed zeros are supported
| > or not.
| >
|
| No, that's incorrect. -0.0 and 0.0 have completely different
| representations and eql makes it clear.
OK, that is an unfortunate literal contradiction between CLHS and
IEEE-754. I'm talking of the IEEE 754 semantics. In IEEE-754,
-0.0 and 0.0 must compare equal; that is not open for interpretation
or debate. The only way you distinguish -0.0 from 0.0 is to ask for
its signbit.
| If signed zeroes are supported
| then eql must return NIL:
|
| CMUCL: (eql -0.0 0.0) -> NIL.
|
| >
| >
| > So far, SBCL which is the other Lisp using native `double' is the only
| > free Lisp which gets it right (my version of CLisp does not pretend to
| > have :IEEE-FLOATING-POINT on its *features*).
| >
| >
| CMUCL has had signed zeroes for over a decade, I think.
So, this is not news for Lisp systems. Good.
|
| There are quite a few people who think signed zeroes without an unsigned
| zero is bad. (I actually like signed zeroes since it makes branch cuts
| easier.)
What do you call `unsigned zero'? And why is it necessary? We have been
successfully writing scientific applications with signed zeros as
described by IEEE 754 for decades. Why is it bad to have signed zero
without the other one? In what concreate situations is it bad to have
signed zeros but not `unsigned zero'?
| Since ecl compiles to C, it might be difficult to get signed zeroes to
| work out right.
This I do not get -- I write daily C and C++ applications with signed
zeros without problems. Please explain in detail why compiling to C
would make it difficult when C already supports it.
-- Gaby
More information about the ecl-devel
mailing list