guile-devel
[Top][All Lists]
Advanced

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

Re: Raising negative numbers to an inexact integer


From: Neil Jerram
Subject: Re: Raising negative numbers to an inexact integer
Date: Tue, 01 Feb 2011 23:17:04 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Mark H Weaver <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]