summaryrefslogtreecommitdiff
path: root/src/inttypes/imaxdiv.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/inttypes/imaxdiv.c')
-rw-r--r--src/inttypes/imaxdiv.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/inttypes/imaxdiv.c b/src/inttypes/imaxdiv.c
new file mode 100644
index 00000000..043cee45
--- /dev/null
+++ b/src/inttypes/imaxdiv.c
@@ -0,0 +1,19 @@
+#include <inttypes.h>
+
+imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom)
+{
+ imaxdiv_t r = {0};
+ if (denom == 0) {
+ /* undefined */
+ return r;
+ }
+ r.quot = numer / denom;
+ r.rem = numer % denom;
+ /* if either cannot be represented, undefined */
+ return r;
+}
+
+
+/*
+STDC(199901)
+*/