[F&O] CER-11 xs:decimal overflow


F&O [6.2] xs:decimal overflow should not happen on rounding

As currently written the expression "1 div 3 * 100" causes a mandatory overflow
error. 

Per F&O 6.2:
   "For xs:decimal operations, overflow behavior ·must· raise an error [numeric
   operation overflow/underflow]. On underflow, 0.0 must be returned." 

Per F&O 6.2.4:
   "As a special case, if the types of both $arg1 and $arg2 are xs:integer,
   then the return type is xs:decimal." 

So 1 and 3 are typed as xs:integer and their division results in an xs:decimal
which cannot be precisely represented, causing an overflow error.  This should
not happen.   

(Note that depending on your reading of the spec, the simple division may not be
an "xs:decimal" operation, but the "* 100" clearly makes it an xs:decimal
operation which will cause an overflow error.)

Solution: Overflow/underflow should happen only for numbers exceeding the
implementation's xs:decimal range, not for precision-related roundings. 

This is especially onerous given that such errors cannot be caught and handled
by the XQuery application; see CER-05.

Received on Tuesday, 17 February 2004 11:10:56 UTC