1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-01-15 12:47:04 +00:00
oot/src/libultra_boot_O2/ldiv.c

29 lines
513 B
C
Raw Normal View History

2020-03-17 04:31:30 +00:00
#include <global.h>
#include <stdlib.h>
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;
}
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;
}