home *** CD-ROM | disk | FTP | other *** search
- ╔════════════════════════════════════════════════════╗
- ║ Lesson 2 Part 090 F-PC 3.5 Tutorial by Jack Brown ║
- ╚════════════════════════════════════════════════════╝
-
- ┌─────────────────────────────────┐
- │ Floored vs Symmetric Division │
- └─────────────────────────────────┘
-
- Here is part of what Robert L. Smith had to say about Floored vs
- Symmetric division in an article that appeared in the September 1983
- issue of Dr. Dobb's Journal.
-
- Integer division is a mathematical function fo two integers ( a dividend
- and a divisor) that yields an integer quotient and an integer remainder.
- That appears to be a fairly straightforwared operation, but there is not
- universal agreement of the desired results when one or both arguments
- are negative. When an integer quotient is usen in plotting or machine
- control, the desired function is usually NOT the quotient given by the
- majority of computers.
-
- Most computers with a divide function produce a quotient that has a
- property of symmetry around zero when plotted as a function of the
- dividend, due to the fact that the quotient is rounded toward zero.
- Speaking mathematically, the property is actually one of antisymmetry,
- where the sign of the quotient is reversed when the sign for the
- dividend (or numerator) is reversed. For integer division, this
- "symmetric" property leads to a sort of discontinuity around zero. In
- this case, the remainder is either zero or it takes the sign of the
- dividend. Figure 1a below illustrates the quotient q as a function of a
- variable dividend and a constant divisor 3.
-
- 10q
- SYMMETRIC q vs m + Divisor = n = 3
- +
- +
- +
- + o
- + o o o
- + o o o
- + o o o
- -10 + o o o 10
- +-+-+-+-+-+-+-+-+-+-+-+-+-o-o-o-o-o-+-+-+-+-+-+-+-+-+-+-+-+-+ m
- o o o +
- o o o +
- o o o +
- o o o +
- o +
- +
- +
- + m = nq + r
- + m/n = q + r/n
- -10
- Quotient vs Dividend for Symmetric Integer Division
- ( m = dividend, n = divisor, q = quotient, and r = remainder)
-
- We can readily see the discontinuity near zero. [ long step!! jwb ]
- This may be reasonalby serious when this quotient function is used ffor
- plotting or moving robot arms.
- ....
- The remainder function for a constand divisor 3 is illusrated in figure
- 1b below:
- 10 r
- SYMMETRIC r vs m + Divisor = n = 3
- +
- +
- +
- +
- +
- +
- + o o o o o
- -10 + o o o o0 o
- o-+-+-o-+-+-o-+-+-o-+-+-o-+-+-o-+-+-o-+-+-o-+-+-o-+-+-o-+-+-o m
- o o o o o +
- o o o o o +
- +
- +
- +
- +
- +
- + m = nq + r
- + m/n = q + r/n
- -10
- Remainder vs Dividend for Symmetric Integer Division
- ( m = dividend, n = divisor, q = quotient, and r = remainder)
-
- If we look at the case of positive dividends and divisors we observe the
- cyclic property as the dividend changes.... This property is not
- maintained for negative dividends.
- ......
-
- ┌────────────────────────────────────┐
- │ Please move to Lesson 2 Part 100 │
- └────────────────────────────────────┘
-