bugGNU Octave - Bugs: bug #49633, display of "minus zero"?

 
 

bug #49633: display of "minus zero"?

Submitter:  Hartmut <hardy>
Submitted:  Thu 17 Nov 2016 06:22:44 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.0.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 18 Nov 2016 07:47:57 AM UTC, comment #4: 

It's not a bug, it's a feature!

"minus zero" is defined in IEEE 754
https://en.wikipedia.org/wiki/Signed_zero

Example:
1 / 0 = Inf
1 / -0 = -Inf

Armin Müller <arm_in>
Thu 17 Nov 2016 07:13:31 PM UTC, comment #3: 

Maybe we should have an option to suppress the negative sign when displaying -0, enabled by default with the --maximum-braindamage option.

John W. Eaton <jwe>
Group administrator
Thu 17 Nov 2016 06:55:43 PM UTC, comment #2: 

Sorry for being too fast with opening a bug report.

I have now also found this: http://stackoverflow.com/questions/2109755/why-does-gnu-octave-have-negative-zeroes

So the "minus zero" seems to be really useful for certain calculations. But why does Octave choose to also display it as an end result? Matlab seems to display it as a zero without a minus sign, when I understand the above post correctly. And I personally was confused because I've never seen any "-0" in Matlab so far.

Just wandering... I'm fine with keeping it this way as well. But it is (slightly) Matlab incompatible.

Hartmut <hardy>
Thu 17 Nov 2016 06:47:29 PM UTC, comment #1: 

Because it is not the same as positive zero.


>> signbit (0)
ans = 0
>> signbit (-0)
ans = 1


It may be equal to positive zero using the == operator, but it is not the same value in binary floating point representation.

Asking about things like this seems better suited for the help mailing list rather than a bug report.

Mike Miller <mtmiller>
Group Member
Thu 17 Nov 2016 06:22:44 PM UTC, original submission:  

Why does Octave display "minus zero", even if it is the same as "zero"?


>> a = -0
a = -0
>> a
a = -0
>> a == 0
ans = 1
>>


Should this be this way? Or should octave skip the display of the minus sign when the absolute value is zero? Octave obviously already knows that -0==0.

Hartmut <hardy>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by arm_in (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by hardy (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-11-17 mtmiller Open/ClosedOpen Closed
    2016-11-17 mtmiller StatusNone Invalid / Not an Octave Bug

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code