. service tells you which device it couldn't stat
[minix3.git] / lib / ack / libm2 / dvi.c
blobd72076defbec2bfe7574d836ebe8107620177e45
1 /*
2 (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 See the copyright notice in the ACK home directory, in the file "Copyright".
4 */
6 /*
7 Module: implementation of DIV and MOD
8 Author: Ceriel J.H. Jacobs
9 Version: $Header$
10 Reason: We cannot use DVI and RMI, because DVI rounds towards 0
11 and Modula-2 requires truncation
14 #include <em_abs.h>
16 int
17 dvi(j,i)
18 int j,i;
20 if (j == 0) TRP(EIDIVZ);
21 if ((i < 0) != (j < 0)) {
22 if (i < 0) i = -i;
23 else j = -j;
24 return -((i+j-1)/j);
26 else return i/j;
29 long
30 dvil(j,i)
31 long j,i;
33 if (j == 0) TRP(EIDIVZ);
34 if ((i < 0) != (j < 0)) {
35 if (i < 0) i = -i;
36 else j = -j;
37 return -((i+j-1)/j);
39 else return i/j;
42 int
43 rmi(j,i)
44 int j,i;
46 if (j == 0) TRP(EIDIVZ);
47 if (i == 0) return 0;
48 if ((i < 0) != (j < 0)) {
49 if (i < 0) i = -i;
50 else j = -j;
51 return j*((i+j-1)/j)-i;
53 else return i%j;
56 long
57 rmil(j,i)
58 long j,i;
60 if (j == 0) TRP(EIDIVZ);
61 if (i == 0) return 0L;
62 if ((i < 0) != (j < 0)) {
63 if (i < 0) i = -i;
64 else j = -j;
65 return j*((i+j-1)/j)-i;
67 else return i%j;