. use library function to parse memory string
[minix3.git] / lib / ansi / ldiv.c
blob42c761977e62075b5074e456c400dfeecd585705
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 long tmp = -1;
11 ldiv_t
12 ldiv(register long numer, register long denom)
14 ldiv_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;