Commons JXPath
  1. Commons JXPath
  2. JXPATH-102

Core rounding functions don't handle NaN or infinite values correctly

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3
    • Fix Version/s: 1.3
    • Labels:
      None

      Description

      assertXPathValue(context, "floor('NaN')", new Double(Double.NaN));
      assertXPathValue(context, "floor(-2 div 0)", new Double(Double.NEGATIVE_INFINITY));
      assertXPathValue(context, "floor(2 div 0)", new Double(Double.POSITIVE_INFINITY));

      assertXPathValue(context, "ceiling('NaN')", new Double(Double.NaN));
      assertXPathValue(context, "ceiling(-2 div 0)", new Double(Double.NEGATIVE_INFINITY));
      assertXPathValue(context, "ceiling(2 div 0)", new Double(Double.POSITIVE_INFINITY));

      assertXPathValue(context, "round('NaN')", new Double(Double.NaN));
      assertXPathValue(context, "round(-2 div 0)", new Double(Double.NEGATIVE_INFINITY));
      assertXPathValue(context, "round(2 div 0)", new Double(Double.POSITIVE_INFINITY));

      1. testcase-patch.txt
        2 kB
        Sergey Vladimirov
      2. patch.txt
        1 kB
        Sergey Vladimirov

        Activity

        Hide
        Matt Benson added a comment -

        The XPath spec is explicit on rounding, but less so on ceiling/floor. However, the spec claims to use IEEE 754 which expresses ceiling/floor in terms of rounding, so I agree that abiding by the same rules in all cases is reasonable. Thanks for the report, Sergey!

        Show
        Matt Benson added a comment - The XPath spec is explicit on rounding, but less so on ceiling/floor. However, the spec claims to use IEEE 754 which expresses ceiling/floor in terms of rounding, so I agree that abiding by the same rules in all cases is reasonable. Thanks for the report, Sergey!

          People

          • Assignee:
            Unassigned
            Reporter:
            Sergey Vladimirov
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development