octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #50947] angle of -0-0i should be 0 for Matlab


From: Rik
Subject: [Octave-bug-tracker] [bug #50947] angle of -0-0i should be 0 for Matlab compatibility
Date: Thu, 4 May 2017 12:15:41 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0

Update of bug #50947 (project octave):

              Item Group:                    None => Matlab Compatibility   
                 Summary: angle of -0-0i should be 0 => angle of -0-0i should
be 0 for Matlab compatibility

    _______________________________________________________

Follow-up Comment #2:

I think this is more of an issue about automatic narrowing and whether Matlab
keeps the sign bit on an IEEE 0.

Because storing complex numbers requires double the amount of storage (real
and imaginary 8-byte numbers), Octave automatically tries to compact to a real
array whenever the complex part is equal to zero.  Try the failing code in two
steps:


octave:1> x = -0-0i
x = -0
octave:2> angle (x)
ans =  3.1416
octave:3> angle (-x)
ans = 0


In the first stage, Octave compacts the value to '-0'.  And the angle of -0 is
pi.  Does Matlab keep the signbit for zero values?  What does the following
return in Matlab?


atan2 (0,0)
atan2 (0,-0)
atan2 (-0,-0)
atan2 (-0,0)


In Octave


octave:7> atan2 (0,0)
ans = 0
octave:8> atan2 (0,-0)
ans =  3.1416
octave:9> atan2 (-0,-0)
ans = -3.1416
octave:10> atan2 (-0,0)
ans = -0




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?50947>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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