Added more remainder tests, and fixed our implementation of remainder to pass the tests
This commit is contained in:
parent
226f8b4ac4
commit
b08d48bd43
|
@ -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,"")); \
|
||||
|
|
|
@ -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); \
|
||||
|
|
Loading…
Reference in New Issue
Block a user