* Raising negative numbers to an inexact integer
[not found] <20110131172444.96D2098298@pluto.mumble.net>
@ 2011-01-31 20:26 ` Mark H Weaver
2011-02-01 23:17 ` Neil Jerram
2011-02-02 20:16 ` Andy Wingo
0 siblings, 2 replies; 3+ messages in thread
From: Mark H Weaver @ 2011-01-31 20:26 UTC (permalink / raw)
To: guile-devel; +Cc: Andy Wingo, Taylor R Campbell
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Raising negative numbers to an inexact integer
2011-01-31 20:26 ` Raising negative numbers to an inexact integer Mark H Weaver
@ 2011-02-01 23:17 ` Neil Jerram
2011-02-02 20:16 ` Andy Wingo
1 sibling, 0 replies; 3+ messages in thread
From: Neil Jerram @ 2011-02-01 23:17 UTC (permalink / raw)
To: Mark H Weaver; +Cc: Andy Wingo, Taylor R Campbell, guile-devel
Mark H Weaver <mhw@netris.org> writes:
> 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?
For what it's worth, that all makes sense to me. (Speaking as someone
who did a lot of mathematics at university, but hasn't used it seriously
since.)
Neil
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Raising negative numbers to an inexact integer
2011-01-31 20:26 ` Raising negative numbers to an inexact integer Mark H Weaver
2011-02-01 23:17 ` Neil Jerram
@ 2011-02-02 20:16 ` Andy Wingo
1 sibling, 0 replies; 3+ messages in thread
From: Andy Wingo @ 2011-02-02 20:16 UTC (permalink / raw)
To: Mark H Weaver; +Cc: Taylor R Campbell, guile-devel
On Mon 31 Jan 2011 21:26, Mark H Weaver <mhw@netris.org> writes:
> 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?
Sounds sane to me.
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-02-02 20:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20110131172444.96D2098298@pluto.mumble.net>
2011-01-31 20:26 ` Raising negative numbers to an inexact integer Mark H Weaver
2011-02-01 23:17 ` Neil Jerram
2011-02-02 20:16 ` Andy Wingo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).