dvi.c

来自「minix3的源代码」· C语言 代码 · 共 69 行

C
69
字号
/*  (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.  See the copyright notice in the ACK home directory, in the file "Copyright".*//*  Module:	implementation of DIV and MOD  Author:	Ceriel J.H. Jacobs  Version:	$Header: /cvsup/minix/src/lib/ack/libm2/dvi.c,v 1.1 2005/10/10 15:27:46 beng Exp $  Reason:	We cannot use DVI and RMI, because DVI rounds towards 0		and Modula-2 requires truncation*/#include <em_abs.h>intdvi(j,i)	int j,i;{	if (j == 0) TRP(EIDIVZ);	if ((i < 0) != (j < 0)) {		if (i < 0) i = -i;		else j = -j;		return -((i+j-1)/j);	}	else return i/j;}longdvil(j,i)	long j,i;{	if (j == 0) TRP(EIDIVZ);	if ((i < 0) != (j < 0)) {		if (i < 0) i = -i;		else j = -j;		return -((i+j-1)/j);	}	else return i/j;}intrmi(j,i)	int j,i;{	if (j == 0) TRP(EIDIVZ);	if (i == 0) return 0;	if ((i < 0) != (j < 0)) {		if (i < 0) i = -i;		else j = -j;		return j*((i+j-1)/j)-i;	}	else return i%j;}longrmil(j,i)	long j,i;{	if (j == 0) TRP(EIDIVZ);	if (i == 0) return 0L;	if ((i < 0) != (j < 0)) {		if (i < 0) i = -i;		else j = -j;		return j*((i+j-1)/j)-i;	}	else return i%j;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?