mirror of
https://github.com/zeldaret/oot.git
synced 2025-01-15 12:47:04 +00:00
28 lines
513 B
C
28 lines
513 B
C
#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;
|
|
}
|