6316
2008-12-16 16:56:32 +0000
[FO] An error should be raised if second argument to op:numeric-integer-divide is INF or -INF
2009-01-28 20:47:23 +0000
1
1
1
Unclassified
XPath / XQuery / XSLT
Functions and Operators 1.0
Recommendation
PC
Windows XP
CLOSED
FIXED
http://www.w3.org/TR/xpath-functions/#func-numeric-integer-divide
P4
normal
---
1
zongaro
mike
andrew.eisenberg
jim.melton
public-qt-comments
oldest_to_newest
22769
0
zongaro
2008-12-16 16:56:32 +0000
The third paragraph of section 6.2.6 of F&O states, "If the divisor is (positive or negative) zero, then an error is raised [err:FOAR0001]. If either operand is NaN or if $arg1 is INF or -INF then an error is raised [err:FOAR0002]."
I think we need to prohibit the second operand from being positive or negative infinity as well. If $a is finite, but $b is not finite, there is no value of type xs:integer that could be delivered as the result of ($a idiv $b) so that the following relation is true.
(($a idiv $b) * $b) + ($a mod $b) = $a
I believe the second sentence should read, "If either operand is NaN, positive infinity or negative infinity, then an error is raised [err:FOAR0002]."
22929
1
andrew.eisenberg
2009-01-05 21:37:20 +0000
I would suggest a different fix fro this problem.
In our Recommendation we said:
"If the dividend, $arg1, is not evenly divided by the divisor, $arg2, then the quotient is the xs:integer value obtained, ignoring (truncating) any remainder that results from the division (that is, no rounding is performed). Thus, the semantics " $a idiv $b " are equivalent to " ($a div $b) cast as xs:integer " except for error situations."
I believe that this leads us to having xs:float("4") idiv xs:float("INF") return 0.
Our editors draft of F&O 1.1/2.1, reflecting our resolution of Bug #6212, says:
"If the divisor is (positive or negative) zero, then an error is raised [err:FOAR0001]. If either operand is NaN or if $arg1 is INF or -INF then an error is raised [err:FOAR0002].
Otherwise, subject to limits of precision and overflow/underflow conditions, the result is the largest (furthest from zero) xs:integer value $N such that fn:abs($N * $arg2) le fn:abs($arg1) and fn:compare($N * $arg2, 0) eq fn:compare($arg1, 0)."
There is no value of $N, where $arg1 is not NaN, INF, or -INF and $arg2 is INF, that satisfies the expression in the second paragraph (remembering that 0 * INF is NaN and NaN le any value is false).
I believe that we should change the first paragraph to say:
"If the divisor is (positive or negative) zero, then an error is raised [err:FOAR0001]. If either operand is NaN or if $arg1 is INF or -INF then an error is raised [err:FOAR0002]. [Insert: If $arg2 is INF or -INF, then the result is 0.]"
22953
2
mike
2009-01-06 16:38:39 +0000
Decided that the result of A idiv INF should be zero. This technically needs no changes to the text, except possibly for clarification.
23284
3
mike
2009-01-28 20:34:35 +0000
Erratum E33 has been drafted to clarify that when the second argument is INF or -INF, the idiv operator returns zero.
I am marking this bug as fixed, if you agree please mark it closed.
23286
4
zongaro
2009-01-28 20:47:23 +0000
I agree with the resolution.