blob: 0b7f01670ca55e656d8fb9593425a96a4251c9e5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#include <limits.h>
#include <stdlib.h>
#include "_stdlib.h"
/** calculate quotient and remainder **/
ldiv_t ldiv(long int numer, long int denom)
{
ldiv_t d;
SIGNAL_SAFE(0);
if ((denom == 0) || (numer == LONG_MIN && denom == -1)) {
UNDEFINED("In call to ldiv(): The result of %ld / %ld is not representable as a long int", numer, denom);
}
d.quot = numer / denom;
d.rem = numer % denom;
return d;
}
CHECK_2(ldiv_t, {0}, ldiv, long int, long int)
/***
computes both the quotient and remainder of ARGUMENT(numer)
divided by ARGUMENT(denom).
***/
/*
UNDEFINED(The result cannot be represented)
RETURN_SUCCESS(a TYPEDEF(ldiv_t) containing both the quotient and remainder)
STDC(1)
*/
|