source: trunk/minix/lib/ack/libp/mdi.c@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 1.3 KB
Line 
1/* $Header: /cvsup/minix/src/lib/ack/libp/mdi.c,v 1.1 2005/10/10 15:27:47 beng Exp $ */
2/*
3 * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
4 *
5 * This product is part of the Amsterdam Compiler Kit.
6 *
7 * Permission to use, sell, duplicate or disclose this software must be
8 * obtained in writing. Requests for such permissions may be sent to
9 *
10 * Dr. Andrew S. Tanenbaum
11 * Wiskundig Seminarium
12 * Vrije Universiteit
13 * Postbox 7161
14 * 1007 MC Amsterdam
15 * The Netherlands
16 *
17 */
18
19/* Author: J.W. Stevenson */
20
21#include <pc_err.h>
22
23extern _trp();
24
25int _mdi(j,i) int j,i; {
26
27 if (j <= 0)
28 _trp(EMOD);
29 i = i % j;
30 if (i < 0)
31 i += j;
32 return(i);
33}
34
35long _mdil(j,i) long j,i; {
36
37 if (j <= 0)
38 _trp(EMOD);
39 i = i % j;
40 if (i < 0)
41 i += j;
42 return(i);
43}
44
45int _dvi(j, i) unsigned int j,i; {
46 int neg = 0;
47
48 if ((int)j < 0) {
49 j = -(int)j; neg = 1;
50 }
51 if ((int)i < 0) {
52 i = -(int)i; neg = !neg;
53 }
54 i = i / j;
55 if (neg) return -(int)i;
56 return i;
57}
58
59long _dvil(j, i) unsigned long j,i; {
60 int neg = 0;
61
62 if ((long)j < 0) {
63 j = -(long)j; neg = 1;
64 }
65 if ((long)i < 0) {
66 i = -(long)i; neg = !neg;
67 }
68 i = i / j;
69 if (neg) return -(long)i;
70 return i;
71}
Note: See TracBrowser for help on using the repository browser.