|
From: | Michael D. Godfrey |
Subject: | About -0 and type complex |
Date: | Tue, 09 Oct 2012 13:22:07 -0400 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120911 Thunderbird/15.0.1 |
I would
just like to ask if the following behavior seems right to you. And, is there a way to set the imaginary part of a complex to -0? octave:46> -(1-1) ans = -0 octave:47> -(1-1) +0i ans = 0 octave:48> -(1-1) -0i ans = -0 ================== The obvious question is: why does the sign of the imaginary part change the sign of the real part? The math definitions for arg(z) and |z| treat the real and imaginary parts symmetrically. I have not found a standard for +-0 for complex, but it would seem reasonable to treat the real and imaginary parts according to the same rule. And, is it a good idea to reduce a complex with +-0 imaginary part to real? Saves space, I know, but the sign is lost. Currently, for complex the rule is: real imag result -0 -0 -0 -0 0 0 0 -0 0 In effect, there is no -0 imaginary part even though -0i affects results. I know that this seems pretty academic, but it is getting in the way of my figuring out the correct corner values of atan2(y,x) for complex arguments (another pretty academic pursuit. I know). If you think this is good enough, I will just add it to the documentation about -0. At least, users should know what is supposed to happen. Michael |
[Prev in Thread] | Current Thread | [Next in Thread] |