Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treatment of -0 #186

Closed
ViralBShah opened this issue Aug 22, 2011 · 1 comment
Closed

Treatment of -0 #186

ViralBShah opened this issue Aug 22, 2011 · 1 comment
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@ViralBShah
Copy link
Member

We seem to convert -0 to 0. The signbit of 0 should be preserved, and -0 should be displayed if signbit is -1.

julia> signbit(0)
1

julia> signbit(-0)
1

MATLAB keeps the sign on zero, but doesn't display it, and even computes sin(-0) as -0.

x = +0

x =

0000000000000000

x = -0

x =

8000000000000000

This stems from the discussion as per http://math.mit.edu/~numericalmath/numericalmath/index.php/Sine, where

sin(-0) should be -0

@StefanKarpinski
Copy link
Member

This is not a bug. There is no negative zero for integer types: -0 is 0. The only reason this works in Matlab is that 0 is actually 0.0 and -0.0 does have a negative sign bit. In Julia, this doesn't happen because 0 is actually an integer.

StefanKarpinski pushed a commit that referenced this issue Feb 8, 2018
RFC: Add compat for at-threads
LilithHafner pushed a commit to LilithHafner/julia that referenced this issue Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants