W3C home > Mailing lists > Public > public-qt-comments@w3.org > February 2004

ORA-FO-177-B: need to specify how to compute the remainder when dividing negative numbers

From: Stephen Buxton <Stephen.Buxton@oracle.com>
Date: 16 Feb 04 14:40:38
Message-Id: <200402162240.i1GMecG21514@rgmgw5.us.oracle.com>
To: public-qt-comments@w3.org

SECTION 6.2.5: op:numeric-integer-divide

The statement "...ignoring any remainder..." is not helpful in
the case that either the numerator or the divisor or both is
negative, since there is no universally accepted definition of 
how to perform such integer divisions.  In SQL, the decision 
was to follow Fortran's MOD and C's fmod functions to define the 
remainder (see ANSI INCITS H2 paper H2-2003-390, available on 
request from Fred Zemke, Oracle).  These precedents both define 
that the sign of the remainder is the same
as the sign of the numerator.  Thus
numerator = divisor * quotient + remainder
where sign(remainder) = sign(numerator)
and abs(remainder) < abs(numerator)
completely specifies the integer quotient and remainder.
This happens to agree with all four of your examples, so it
is presumably what you meant.  This is corroborated by the
discussion in 6.2.6 op:numeric-mod.

- Steve B.
Received on Monday, 16 February 2004 17:40:40 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:45:17 UTC