summaryrefslogtreecommitdiff
path: root/src/inttypes/imaxdiv.c
blob: b8344e5afdbb3a7f3d413bda67a73d49bbf8a98b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "stddef.h"
#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)
*/