BUG: Display Arithmetic Zero not Signed Zero aka 0 not -0
See original GitHub issuePandas version checks
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
>>> import pandas as pd
>>> pd
<module 'pandas' from 'C:\\Users\\User\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\pandas\\__init__.py'>
>>> pd.__version__
'1.4.3'
>>> pd.Series([1,None,0])*-1
0 -1.0
1 NaN
2 -0.0
dtype: float64
>>>
Issue Description
0 is being returned with a negative sign ie -0.0
Expected Behavior
There should be no negative on zero ie 0 * -1 = 0
Installed Versions
pd.version ‘1.4.3’
Issue Analytics
- State:
- Created a year ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Why computers have two floating point zeros: +0 and -0
Here's a strange detail of IEEE floating point arithmetic: computers have two versions of 0: positive zero and negative zero.
Read more >Signed zero
Signed zero is zero with an associated sign. In ordinary arithmetic, the number 0 does not have a sign, so that −0, +0...
Read more >When is a zero not a zero? - Revolution Analytics
The short answer is that R, like pretty much every other numerical software in existence, uses floating point arithmetic to do its calculations....
Read more >Handling the ArithmeticException Runtime Exception in Java
The ArithmeticException in Java is thrown by the JVM when an arithmetic operation creates an exceptional condition.
Read more >algebra precalculus - Zero to the zero power – is $0^0=1
In Calculus and algebra, there is no reasonable definition (the closest you can come up with is trying to justify it via the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This behavior mimics numpy
Generally, -0 is defined by IEEE and essentially acts like 0/+0. https://stackoverflow.com/a/4083431
Nonetheless, if this behavior was undesirable, it would need to be fixed in numpy/CPython so closing as a potential upstream issue.
https://github.com/python/cpython or https://github.com/numpy/numpy