diff options
| author | Chris Burdess <dog@bluezoo.org> | 2005-08-28 09:05:44 +0000 |
|---|---|---|
| committer | Chris Burdess <dog@bluezoo.org> | 2005-08-28 09:05:44 +0000 |
| commit | 5d6e63e8fc39b60710c81700f3faa7cdd21eeb60 (patch) | |
| tree | 3cecb0383409f437b30060460e722d8243901c9a /gnu/xml/xpath/ArithmeticExpr.java | |
| parent | d00b8c3c72742ce8b2650c26dbd990b2ff34d00d (diff) | |
| download | classpath-5d6e63e8fc39b60710c81700f3faa7cdd21eeb60.tar.gz | |
2005-08-28 Chris Burdess <dog@gnu.org>
* gnu/xml/xpath/ArithmeticExpr.java: Fix div and mod by zero to
follow IEEE rules.
Diffstat (limited to 'gnu/xml/xpath/ArithmeticExpr.java')
| -rw-r--r-- | gnu/xml/xpath/ArithmeticExpr.java | 28 |
1 files changed, 21 insertions, 7 deletions
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: |
