diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | gnu/xml/xpath/ArithmeticExpr.java | 28 |
2 files changed, 26 insertions, 7 deletions
@@ -1,3 +1,8 @@ +2005-08-28 Chris Burdess <dog@gnu.org> + + * gnu/xml/xpath/ArithmeticExpr.java: Fix div and mod by zero to + follow IEEE rules. + 2005-08-27 Tom Tromey <tromey@redhat.com> * m4/acinclude.m4 (CLASSPATH_WITH_GLIBJ): Always check for 'zip' diff --git a/gnu/xml/xpath/ArithmeticExpr.java b/gnu/xml/xpath/ArithmeticExpr.java index 3cef4adf3..cbc1ee064 100644 --- a/gnu/xml/xpath/ArithmeticExpr.java +++ b/gnu/xml/xpath/ArithmeticExpr.java @@ -95,17 +95,31 @@ final class ArithmeticExpr case DIVIDE: if (rn == 0.0d || rn == -0.0d) { - return new Double(ln < 0.0d ? - Double.NEGATIVE_INFINITY : - Double.POSITIVE_INFINITY); + if (ln == 0.0d || ln == -0.0d) + { + return new Double(Double.NaN); + } + else + { + return new Double(ln < 0.0d ? + Double.NEGATIVE_INFINITY : + Double.POSITIVE_INFINITY); + } } return new Double(ln / rn); case MODULO: - if (rn == 0.0d || rn == -0.0d) + if (rn == 0.0d || rn == 0.0d) { - return new Double(ln < 0.0d ? - Double.NEGATIVE_INFINITY : - Double.POSITIVE_INFINITY); + if (ln == 0.0d || ln == -0.0d) + { + return new Double(Double.NaN); + } + else + { + return new Double(ln < 0.0d ? + Double.NEGATIVE_INFINITY : + Double.POSITIVE_INFINITY); + } } return new Double(ln % rn); default: |