summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--gnu/xml/xpath/ArithmeticExpr.java28
2 files changed, 26 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 54e905b2f..90fba014e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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: