Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libm / mathfp / s_fabs.c
blob10e89ef06962a9615ef65fa3c6a77dcf96eb0c35
2 /* @(#)z_fabs.c 1.0 98/08/13 */
4 /*
5 FUNCTION
6 <<fabs>>, <<fabsf>>---absolute value (magnitude)
7 INDEX
8 fabs
9 INDEX
10 fabsf
12 SYNOPSIS
13 #include <math.h>
14 double fabs(double <[x]>);
15 float fabsf(float <[x]>);
17 DESCRIPTION
18 <<fabs>> and <<fabsf>> calculate
19 @tex
20 $|x|$,
21 @end tex
22 the absolute value (magnitude) of the argument <[x]>, by direct
23 manipulation of the bit representation of <[x]>.
25 RETURNS
26 The calculated value is returned.
28 PORTABILITY
29 <<fabs>> is ANSI.
30 <<fabsf>> is an extension.
34 /******************************************************************
35 * Floating-Point Absolute Value
37 * Input:
38 * x - floating-point number
40 * Output:
41 * absolute value of x
43 * Description:
44 * fabs computes the absolute value of a floating point number.
46 *****************************************************************/
48 #include "fdlibm.h"
49 #include "zmath.h"
51 #ifndef _DOUBLE_IS_32BITS
53 double
54 fabs (double x)
56 switch (numtest (x))
58 case NAN:
59 errno = EDOM;
60 return (x);
61 case INF:
62 errno = ERANGE;
63 return (x);
64 case 0:
65 return (0.0);
66 default:
67 return (x < 0.0 ? -x : x);
71 #endif /* _DOUBLE_IS_32BITS */