1FABS(3P)                   POSIX Programmer's Manual                  FABS(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       fabs, fabsf, fabsl — absolute value function
13

SYNOPSIS

15       #include <math.h>
16
17       double fabs(double x);
18       float fabsf(float x);
19       long double fabsl(long double x);
20

DESCRIPTION

22       The functionality described on this reference page is aligned with  the
23       ISO C  standard.  Any  conflict between the requirements described here
24       and the ISO C standard is unintentional. This  volume  of  POSIX.1‐2017
25       defers to the ISO C standard.
26
27       These  functions  shall  compute  the  absolute value of their argument
28       x,|x|.
29

RETURN VALUE

31       Upon successful completion, these functions shall return  the  absolute
32       value of x.
33
34       If x is NaN, a NaN shall be returned.
35
36       If x is ±0, +0 shall be returned.
37
38       If x is ±Inf, +Inf shall be returned.
39

ERRORS

41       No errors are defined.
42
43       The following sections are informative.
44

EXAMPLES

46   Computing the 1-Norm of a Floating-Point Vector
47       This  example shows the use of fabs() to compute the 1-norm of a vector
48       defined as follows:
49
50
51           norm1(v) = |v[0]| + |v[1]| + ... + |v[n-1]|
52
53       where |x| denotes the absolute value  of  x,  n  denotes  the  vector's
54       dimension v[i] denotes the i-th component of v (0≤i<n).
55
56
57           #include <math.h>
58
59           double
60           norm1(const double v[], const int n)
61           {
62               int     i;
63               double  n1_v;  /* 1-norm of v */
64
65               n1_v = 0;
66               for (i=0; i<n; i++) {
67                   n1_v += fabs (v[i]);
68               }
69
70               return n1_v;
71           }
72

APPLICATION USAGE

74       None.
75

RATIONALE

77       None.
78

FUTURE DIRECTIONS

80       None.
81

SEE ALSO

83       isnan()
84
85       The Base Definitions volume of POSIX.1‐2017, <math.h>
86
88       Portions  of  this text are reprinted and reproduced in electronic form
89       from IEEE Std 1003.1-2017, Standard for Information Technology --  Por‐
90       table  Operating System Interface (POSIX), The Open Group Base Specifi‐
91       cations Issue 7, 2018 Edition, Copyright (C) 2018 by the  Institute  of
92       Electrical  and  Electronics Engineers, Inc and The Open Group.  In the
93       event of any discrepancy between this version and the original IEEE and
94       The  Open Group Standard, the original IEEE and The Open Group Standard
95       is the referee document. The original Standard can be  obtained  online
96       at http://www.opengroup.org/unix/online.html .
97
98       Any  typographical  or  formatting  errors that appear in this page are
99       most likely to have been introduced during the conversion of the source
100       files  to  man page format. To report such errors, see https://www.ker
101       nel.org/doc/man-pages/reporting_bugs.html .
102
103
104
105IEEE/The Open Group                  2017                             FABS(3P)
Impressum