map in kernel in 4MB, global-bit-set 'pages' if hardware
[minix.git] / lib / ansi / div.c
blob79c35a33ed8bdbf111caad70739c663c7b40066f
1 /*
2 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
4 */
5 /* $Header$ */
7 #include <stdlib.h>
9 static int tmp = -1;
11 div_t
12 div(register int numer, register int denom)
14 div_t r;
16 /* The assignment of tmp should not be optimized !! */
17 if (tmp == -1) {
18 tmp = (tmp / 2 == 0);
20 if (numer == 0) {
21 r.quot = numer / denom; /* might trap if denom == 0 */
22 r.rem = numer % denom;
23 } else if ( !tmp && ((numer < 0) != (denom < 0))) {
24 r.quot = (numer / denom) + 1;
25 r.rem = numer - (numer / denom + 1) * denom;
26 } else {
27 r.quot = numer / denom;
28 r.rem = numer % denom;
30 return r;