summaryrefslogtreecommitdiff
path: root/src/math/fabs.c
blob: 7fb29369b67c7c0c68ec4ee20a49d8427055c17a (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
36
37
38
39
40
#if 0

# define TGSOURCE "fabs.c"
#include <errno.h>
#include <math.h>
#include "_tgmath.h"

/** absolute value **/

TYPE TGFN(fabs)(TYPE x)
{
	SIGNAL_SAFE(0);
	switch (fpclassify(x)) {
	case FP_ZERO:		return 0.0;
	case FP_INFINITE:	return INFINITY;
	default:		break;
	}

	if (0) {
		errno = ERANGE; /* The result cannot be represented */
		/* RETURN_FAILURE(CONSTANT(HUGE_VAL), A range error occurred); */
		return TGHUGE;
	}

	/* RETURN_SUCCESS(ABS(ARGUMENT(x))); */
	return signbit(x) ? -x : x;
}

/***
compute the absolute value of a floating-point number ARGUMENT(x).
***/

/*
IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL))
LINK(m)
STDC(1)
*/


#endif