diff --git a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/expression/AbstractFractionSym.java b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/expression/AbstractFractionSym.java index 243d8c8bca..9680f7113d 100644 --- a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/expression/AbstractFractionSym.java +++ b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/expression/AbstractFractionSym.java @@ -435,7 +435,7 @@ public int compareTo(IExpr expr) { return c; } IExpr im = expr.im(); - return !im.isPositive() ? 1 : -1; + return im.isPositive() ? -1 : im.isNegative() ? 1 : IExpr.compareHierarchy(this, expr); } return IExpr.compareHierarchy(this, expr); } diff --git a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/expression/AbstractIntegerSym.java b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/expression/AbstractIntegerSym.java index b748a91792..6fd107777b 100644 --- a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/expression/AbstractIntegerSym.java +++ b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/expression/AbstractIntegerSym.java @@ -380,7 +380,7 @@ public int compareTo(final IExpr expr) { return c; } IExpr im = expr.im(); - return !im.isPositive() ? 1 : -1; + return im.isPositive() ? -1 : im.isNegative() ? 1 : IExpr.compareHierarchy(this, expr); } return IExpr.compareHierarchy(this, expr); } diff --git a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/expression/Num.java b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/expression/Num.java index ec04cd6357..8d97f54dff 100644 --- a/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/expression/Num.java +++ b/symja_android_library/matheclipse-core/src/main/java/org/matheclipse/core/expression/Num.java @@ -231,6 +231,8 @@ public int compareTo(final IExpr expr) { if (c != 0) { return c; } + IExpr im = expr.im(); + return im.isPositive() ? -1 : im.isNegative() ? 1 : IExpr.compareHierarchy(this, expr); } return IExpr.compareHierarchy(this, expr); }