arith.c
上传用户:shmaik
上传日期:2014-06-01
资源大小:45093k
文件大小:1k
- static char rcsid[] = "$Id: H:/drh/idioms/book/RCS/inter.doc,v 1.11 1997/02/21 19:42:15 drh Exp $";
- #include "arith.h"
- int Arith_max(int x, int y) {
- return x > y ? x : y;
- }
- int Arith_min(int x, int y) {
- return x > y ? y : x;
- }
- int Arith_div(int x, int y) {
- if (-13/5 == -2
- && (x < 0) != (y < 0) && x%y != 0)
- return x/y - 1;
- else
- return x/y;
- }
- int Arith_mod(int x, int y) {
- if (-13/5 == -2
- && (x < 0) != (y < 0) && x%y != 0)
- return x%y + y;
- else
- return x%y;
- }
- int Arith_floor(int x, int y) {
- return Arith_div(x, y);
- }
- int Arith_ceiling(int x, int y) {
- return Arith_div(x, y) + (x%y != 0);
- }