Fwd: [R6RS] Preparation for next meeting
dyb at cs.indiana.edu
Thu May 19 21:40:34 EDT 2005
> However, they should be = (for consistency with numeric equality in
> IEEE754), so
> (= +0.0 -0.0) => #t
> To me a real is a complex number with an exact 0 imaginary part.
That seems like a reasonable interpretation. Another possibility is
that a real is a complex number with an inexact zero imaginary part of
unknown sign, with imag-part always choosing +0.0 when forced to coerce
the imaginary part to a float. It may seem arbitrary for imag-part to
choose +0.0, but no more arbitrary than + choosing +0.0 for the sum of
+0.0 and -0.0.
By the way, would you also have (real-part +1.0i) return exact 0, which
requires the introduction of an imaginary type (at least internally)
separate from the complex type, or is it okay to be asymmetric and treat
+1.0i as an abbreviation for 0.0+1.0i?
> complex number with an inexact imaginary part, even +0.0 or -0.0,
> should not be real?, i.e.
> (real? 1.0+0.0i) => #f
> (real? 1.0-0.0i) => #f
This also seems reasonable. In fact, they *can't* be real with the
interpretation of +0.0 as just slightly over zero and -0.0 as just
slightly under zero. The same reasoning can be applied to integer?:
(integer? 0.0) => #f
(integer? -0.0) => #f
In fact, (integer? N.0) should be false for all N, since we can't
tell that an inexact quantity is really an integer unless we have
more information than the IEEE floating-point representations give us.
This would lead to some rather strange results, however, like:
(integer? (truncate .5)) => #f
More information about the R6RS