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

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