sm64pc/lib/src/ldiv.c

29 lines
524 B
C

#include "libultra_internal.h"
#include <stdlib.h>
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;
}