sm64ex-coop/lib/src/ldiv.c

33 lines
548 B
C

#include "libultra_internal.h"
#include "stdlib.h"
#ifdef NO_LDIV
lldiv_t lldiv(long long num, long long denom) {
lldiv_t ret;
ret.quot = num / denom;
ret.rem = num - denom * ret.quot;
if (ret.quot < 0 && ret.rem > 0) {
ret.quot++;
ret.rem -= denom;
}
return ret;
}
ldiv_t ldiv(long num, long denom) {
ldiv_t ret;
ret.quot = num / denom;
ret.rem = num - denom * ret.quot;
if (ret.quot < 0 && ret.rem > 0) {
ret.quot++;
ret.rem -= denom;
}
return ret;
}
#endif