[Bug 4621] [F&O] rounding for duration *|div number

http://www.w3.org/Bugs/Public/show_bug.cgi?id=4621

           Summary: [F&O] rounding for duration *|div number
           Product: XPath / XQuery / XSLT
           Version: Recommendation
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Functions and Operators
        AssignedTo: ashok.malhotra@oracle.com
        ReportedBy: mike@saxonica.com
         QAContact: public-qt-comments@w3.org


This arises from bug 713 (member-only) against the XSLT test suite.

What is the correct result of xs:yearMonthDuration('-P1M')*0.5, or
xs:yearMonthDuration('-P1M') div 2? 

The spec says (10.6.3, 10.6.4) "The result is rounded to the nearest month. For
a value v, 0 <= v < 0.5 rounds to 0; 0.5 <= v < 1.0 rounds to 1." It's not
clear from that which way the rounding works for negative numbers.

My proposal would be to follow the rules of the round() function, so -0.5
rounds to 0. Specifically, the result should be the yearMonthDuration whose
length in months is equal to round() applied to result of multiplying/dividing
the length in months of $arg1 by the value of $arg2.

Received on Sunday, 10 June 2007 23:38:56 UTC