wmb@MITCH.ENG.SUN.COM (Mitch Bradley) (02/28/91)
> This is an emprical proof of the fact that the forms of division used in > most of the current computer languages (Including the two used in the > BASIS...) are incorrect in the results given for the remainder for > operations in the third quadrant (both divisor and dividend are > negative). ... > Consider, > -4 > -4 -3 /MOD is equivalent to -- in fractional expression terms. > -3 Sorry, this isn't correct. The mathematical definition of signed integer division with remainder is the following equation holds: quotient*divisor + remainder = dividend There are several ways of arranging the signs to make this work out correctly; the mathematical "mod" function arranges the signs so that that, if the remainder is nonzero, its sign is the same as the divisor's. Reference: Knuth "The Art of Computer Programming", Vol. 1. There are other choices, but the Forth-83 choice is definitely mathematically correct, and there is considerable evidence to suggest that it is the best choice for many if not most numerical applications. Robert Berkey has written extensively on this topic, and rather than recap his arguments, I refer interested readers to the literature. Following up on the example presented, let's recast it in fractional form: remainder dividend quotient + --------- = -------- divisor divisor -1 -4 1 + --------- = -------- -3 -3 Thus we see that the error in the original argument stems from the fact that, which the signs of the dividend and divisor cancel out, the fractional representation implies that the remainder is also divided by the divisor. In order for the divisor's sign to be canceled in the remainder term, the remainder must be negative. Mitch
S47852EF@ETSUACAD.BITNET ("Frank C. Earl") (03/01/91)
On Wed, 27 Feb 91 15:46:01 PST Mitch Bradley said: > >Sorry, this isn't correct. The mathematical definition of signed >integer division with remainder is the following equation holds: > > quotient*divisor + remainder = dividend > But it *is* correct- a fractional representation is simply what you just said From what I was told from 1st and second grade on, a fraction is the same thing a division operation and that integer division returns the whole number result and the divisor of the left over fraction, or in other words- 4 1 - = 4 / 3 = 1.33333 which is approximately equal to 1 + - . 3 3 I get the SAME results from a calculator- ANY calculator. Also, all the calculators in my house give me the *SAME* result for -4 /-3. If, I'm wrong, then ALL the calculators we use are also wrong... (I don't think anybody wants to touch that w/ a 10-ft pole... :) >There are other choices, but the Forth-83 choice is definitely mathematically >correct, and there is considerable evidence to suggest that it is the >best choice for many if not most numerical applications. Robert Berkey >has written extensively on this topic, and rather than recap his arguments, >I refer interested readers to the literature. > >Following up on the example presented, let's recast it in fractional form: > > remainder dividend > quotient + --------- = -------- > divisor divisor > > -1 -4 > 1 + --------- = -------- > -3 -3 > >Thus we see that the error in the original argument stems from the fact >that, which the signs of the dividend and divisor cancel out, the >fractional representation implies that the remainder is also divided >by the divisor. In order for the divisor's sign to be canceled in the >remainder term, the remainder must be negative. > >Mitch Your example didn't come ove the net well at all... Please re-post it if you'd like. It really doesn't show any errors in my reasoning at all in the form that I got... BTW- One of my grad instructors has checked my reasoning and he agrees; this coming from a math instructor, has me thinking that something's awry... Thanks, Frank