Added more remainder tests, and fixed our implementation of remainder to pass the tests

This commit is contained in:
Neil Brown 2009-01-22 12:58:53 +00:00
parent 226f8b4ac4
commit b08d48bd43
2 changed files with 7 additions and 2 deletions

View File

@ -125,6 +125,10 @@ int g_stopped;
testf(f(-max-1,0,"")); \
testp(0,f(max,max,"")); \
testp(0,f(-max-1,-max-1,"")); \
testp(-2,f(-max-1,max>>1,"")); \
testp(-2,f(-max-1,-(max>>1),"")); \
testp(-1,f(-max,max>>1,"")); \
testp(-1,f(-max,-(max>>1),"")); \
testp(-1,f(-max-1,-max,"")); \
testp(-1,f(-max-1,max,"")); \
testp(3,f(3,-max-1,"")); \

View File

@ -177,8 +177,9 @@ static inline int occam_check_retype (int src, int dest, const char *pos) {
static inline type occam_rem_##type (type a, type b, const char *pos) { \
if (b == 0) { \
occam_stop (pos, 1, "modulo by zero"); \
} \
if (a < 0) { \
} else if (a == __MIN(type)) { \
return a % (b < 0 ? -b : b); \
} else if (a < 0) { \
return -((-a) % (b < 0 ? -b : b)); \
} else { \
return a % (b < 0 ? -b : b); \