Skip to content

Commit

Permalink
Change negate so that -0 and -0.0 behave as CPython behaves (no USub …
Browse files Browse the repository at this point in the history
…node, just

negate zero).
  • Loading branch information
fwierzbicki committed Jan 15, 2009
1 parent 2394b84 commit 5c64b5f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/org/python/antlr/GrammarActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ expr negate(PythonTree t, expr o) {
Num num = (Num)o;
if (num.getInternalN() instanceof PyInteger) {
int v = ((PyInteger)num.getInternalN()).getValue();
if (v > 0) {
if (v >= 0) {
num.setN(new PyInteger(-v));
return num;
}
Expand All @@ -495,13 +495,13 @@ expr negate(PythonTree t, expr o) {
}
} else if (num.getInternalN() instanceof PyFloat) {
double v = ((PyFloat)num.getInternalN()).getValue();
if (v > 0) {
if (v >= 0) {
num.setN(new PyFloat(-v));
return num;
}
} else if (num.getInternalN() instanceof PyComplex) {
double v = ((PyComplex)num.getInternalN()).imag;
if (v > 0) {
if (v >= 0) {
num.setN(new PyComplex(0,-v));
return num;
}
Expand Down

0 comments on commit 5c64b5f

Please sign in to comment.