mirror of
https://github.com/zeldaret/oot.git
synced 2025-04-06 14:46:21 +00:00
27 lines
493 B
C
27 lines
493 B
C
#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;
|
|
}
|