[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Raising negative numbers to an inexact integer
From: |
Mark H Weaver |
Subject: |
Raising negative numbers to an inexact integer |
Date: |
Mon, 31 Jan 2011 15:26:09 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
Hello all,
I have a local branch which allows Guile to represent non-real complex
numbers with inexact zero imaginary part, such as 1.0+0.0i. Currently,
Guile automatically converts these numbers into reals. As pointed out
by Taylor Campbell and others, it is important to distinguish -1.0+0.0i
from -1.0-0.0i in order to handle branch cuts properly.
In one of my pending patches (not yet submitted), I made sure that
any negative number (or -0.0) raised to any inexact power always yields
a non-real complex number.
For example, although (expt -1.0 2) yields 1.0, (expt -1 2.0) yields
1.0+0.0i, which is not `real?' according to the R6RS. The R6RS requires
that `real?' return #t only if the imaginary part is an _exact_ 0.
Note that operations requiring reals, including the comparison operators
`<', '>', '<=' and '>=' will raise an exception if applied to these
numbers. However, I made sure that `inexact->exact' would ignore an
inexact zero imaginary part.
I don't expect this to be a problem, since anyone raising a negative
number to an inexact power should expect that the result may not be
real.
What do you think?
Mark
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Raising negative numbers to an inexact integer,
Mark H Weaver <=