On 16 January 2007 18:23, Robert Dewar wrote: > Gabriel Paubert wrote: > \ >> No, because the instruction has actually two result values: >> >> - the remainder, which you could safely set to zero (not 1!) >> >> - the quotient, which is affected by the overflow and there may be >> compiler and languages that rely on the exception being generated. > > But the division is undefined, programs have no right to > rely on an exception being generated.
It really depends whether you think of the % operator as being an atomic mathematical operation, or a compound function involving real division and multiplication and subtraction. I think the wording of the standard says only that the inequality "(a/b)*b + a%b == a" does not hold when (a/b) cannot be represented, but does not deny the modulo operator the option of just returning the correct result, which is representable. cheers, DaveK -- Can't think of a witty .sigline today....