Bug / Issue Tracking Service
Bugzilla – Bug 4621
[FO] rounding for duration *|div number
Last modified: 2007-11-16 09:18:58 UTC
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.
Makes sense. In fact, we should say that the result is computed using fn:round().
Proposed change: 1. Change the summary of the two functions from Summary: Returns the result of [multiplying|dividing] the value of $arg1 by $arg2. 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. to Summary: Returns the result of [multiplying|dividing] the value of $arg1 by $arg2. The result is rounded to the nearest month. 2. Add immediately after the summary of each function, the paragraph: The result is the xs:yearMonthDuration whose length in months is equal to the result of applying the fn:round function to the value obtained by [multiplying|dividing] the length in months of $arg1 by the value of $arg2.
This wording was accepted by the WGs on 27 June 2007
Erratum FO-E12 has been drafted.