blob: 98091880e2a89edcbfdf3afd35e88bb43a50421c (
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
33
34
35
|
# define TGSOURCE "fmod.c"
#include <math.h>
#include "nonstd/tgmath.h"
#include "errno.h"
/** floating-point remainder **/
TYPE TGFN(fmod)(TYPE x, TYPE y)
{
if (y == 0) {
return 0;
}
if (0) {
errno = ERANGE; /* The result cannot be represented */
/* RETURN_FAILURE(CONSTANT(HUGE_VAL), A range error occurred); */
return TGHUGE;
}
/* RETURN_SUCCESS(ARGUMENT(x) - VAR(i) * ARGUMENT(y)); */
return x - x / y;
}
/***
compute the floating-point remainder of ARGUMENT(x)/ARGUMENT(y).
FIXME: I am not sure I understand this.
***/
/*
IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL))
IMPLEMENTATION(Whether ARGUMENT(y) being LITERAL(0) results in a domain error or THIS() returning LITERAL(0))
LINK(m)
*/
/*
STDC(1)
*/
|