Issue2159

classification
Title: math.sqrt should throw domain error for all negative values
Type: behaviour Severity: normal
Components: Library Versions: Jython 2.7
Milestone:
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: santa4nt, tkohn, zyasoft
Priority: Keywords:

Created on 2014-06-03.09:35:22 by tkohn, last changed 2014-06-18.19:36:48 by zyasoft.

Messages
msg8595 (view) Author: Tobias Kohn (tkohn) Date: 2014-06-03.09:39:49
The function sqrt from the math-module throws a "math domain error" for the argument "-1" but not for other negative values such as "-2". It should raise a "math domain error" for all negative arguments.

The "sqrt" function in math.java (Jython 2.7) should be changed to (note the "v < ZERO" instead of "v == MINUS_ONE"):

    public static double sqrt(double v) {
        if (isnan(v)) {
            return v;
        }
        if (ispinf(v)) {
            return v;
        }
        if (isninf(v) || v < ZERO) {
            throwMathDomainValueError();
        }
        return Math.sqrt(v);
    }
msg8597 (view) Author: Santoso Wijaya (santa4nt) Date: 2014-06-03.20:50:31
This has already been addressed in this commit: https://bitbucket.org/jython/jython/diff/src/org/python/modules/math.java?diff2=a5b000944a51&at=default

For issue #2140.
msg8682 (view) Author: Jim Baker (zyasoft) Date: 2014-06-18.19:36:48
Duplicate of #2140 per msg8597
History
Date User Action Args
2014-06-18 19:36:48zyasoftsetstatus: open -> closed
resolution: duplicate
messages: + msg8682
nosy: + zyasoft
2014-06-03 20:50:31santa4ntsetnosy: + santa4nt
messages: + msg8597
versions: + Jython 2.7
2014-06-03 09:39:49tkohnsetmessages: + msg8595
2014-06-03 09:35:22tkohncreate