blob: 8ee93b162a0fe26f36cfe9ab89e50da8f54c3a68 (
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
41
42
43
44
|
/* @(#)z_fabsf.c 1.0 98/08/13 */
/******************************************************************
* Floating-Point Absolute Value
*
* Input:
* x - floating-point number
*
* Output:
* absolute value of x
*
* Description:
* fabs computes the absolute value of a floating point number.
*
*****************************************************************/
#include "fdlibm.h"
#include "zmath.h"
float
fabsf (float x)
{
switch (numtestf (x))
{
case NAN:
errno = EDOM;
return (x);
case INF:
errno = ERANGE;
return (x);
case 0:
return (0.0);
default:
return (x < 0.0 ? -x : x);
}
}
#ifdef _DOUBLE_IS_32BITS
double fabs (double x)
{
return (double) fabsf ((float) x);
}
#endif /* defined(_DOUBLE_IS_32BITS) */
|