- From: Ashok Malhotra <ashokma@microsoft.com>
- Date: Fri, 25 Apr 2003 05:31:22 -0700
- To: <public-qt-comments@w3.org>
- Message-ID: <E5B814702B65CB4DA51644580E4853FB07F410E0@red-msg-12.redmond.corp.microsoft.com>
The Functions and Operators taskforce discussed this question at yesterday's telcon. Their recommendation is as follows: The signature of op:numeric-divide is: op:numeric-divide($operand1 as numeric, $operand2 as numeric) as numeric The general rule for operands to numeric types says... "Operands of type xdt:untypedAtomic are converted to xs:double, ..., If the two operands are not of the same type, subtype substitution and type promotion are used to obtain two operands of the same type." Thus, the operands are first converted to a common type. If this common type is xs:float or xs:double, floating point division is performed. If this common type is xs;decimal or xs:integer the divisor is first checked. If it is zero, a "division by zero" error is raised. If not, decimal division is performed. The taskforce decided that no change was needed but it may be desirable to add an explanatory example to clarify the rules. All the best, Ashok _____ From: public-qt-comments-request@w3.org [mailto:public-qt-comments-request@w3.org] On Behalf Of Ashok Malhotra Sent: Friday, April 18, 2003 11:32 AM To: public-qt-comments@w3.org The definition of op:numeric-divide is not specific enough in how integer and decimal operands should be handled. Should they be converted to double and a zero divisor be handled by the double division returning + or -INF, or should the divisor be checked for zero before converting to double. I suggest we change the details to one of the paragraphs below. My, not very strong, preference is the first paragraph. For xs:decimal and xs:integer operands, the operands are first converted to xs:double. For xs:float and xs:double operands, floating point division is preformed as specified in <http://lists.w3.org/Archives/Member/w3c-archive/2003Feb/att-0150/xquery -operators.html> [IEEE 754-1985]. For xs:decimal and xs:integer operands, the divisor is checked first. If it is 0, then an error is raised ("Division by zero"). The operands are then converted to xs:double. For xs:float and xs:double operands, floating point division is preformed as specified in <http://lists.w3.org/Archives/Member/w3c-archive/2003Feb/att-0150/xquery -operators.html> [IEEE 754-1985]. All the best, Ashok
Received on Friday, 25 April 2003 08:31:35 UTC