1SQRT(3P)                   POSIX Programmer's Manual                  SQRT(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
11       delim $$
12

NAME

14       sqrt, sqrtf, sqrtl — square root function
15

SYNOPSIS

17       #include <math.h>
18
19       double sqrt(double x);
20       float sqrtf(float x);
21       long double sqrtl(long double x);
22

DESCRIPTION

24       The functionality described on this reference page is aligned with  the
25       ISO C  standard.  Any  conflict between the requirements described here
26       and the ISO C standard is unintentional. This  volume  of  POSIX.1‐2008
27       defers to the ISO C standard.
28
29       These  functions  shall  compute  the  square root of their argument x,
30       $sqrt {x}$.
31
32       An application wishing to check for error situations should  set  errno
33       to  zero  and  call  feclearexcept(FE_ALL_EXCEPT)  before calling these
34       functions. On return, if errno is non-zero or fetestexcept(FE_INVALID |
35       FE_DIVBYZERO  |  FE_OVERFLOW  | FE_UNDERFLOW) is non-zero, an error has
36       occurred.
37

RETURN VALUE

39       Upon successful completion, these functions  shall  return  the  square
40       root of x.
41
42       For  finite  values of x < −0, a domain error shall occur, and either a
43       NaN  (if  supported),  or  an  implementation-defined  value  shall  be
44       returned.
45
46       If x is NaN, a NaN shall be returned.
47
48       If x is ±0 or +Inf, x shall be returned.
49
50       If x is −Inf, a domain error shall occur, and a NaN shall be returned.
51

ERRORS

53       These functions shall fail if:
54
55       Domain Error
56                   The finite value of x is < −0, or x is −Inf.
57
58                   If  the  integer expression (math_errhandling & MATH_ERRNO)
59                   is non-zero, then errno shall be set  to  [EDOM].   If  the
60                   integer  expression  (math_errhandling & MATH_ERREXCEPT) is
61                   non-zero, then the invalid floating-point  exception  shall
62                   be raised.
63
64       The following sections are informative.
65

EXAMPLES

67   Taking the Square Root of 9.0
68           #include <math.h>
69           ...
70           double x = 9.0;
71           double result;
72           ...
73           result = sqrt(x);
74

APPLICATION USAGE

76       On   error,   the   expressions  (math_errhandling  &  MATH_ERRNO)  and
77       (math_errhandling & MATH_ERREXCEPT) are independent of each other,  but
78       at least one of them must be non-zero.
79

RATIONALE

81       None.
82

FUTURE DIRECTIONS

84       None.
85

SEE ALSO

87       feclearexcept(), fetestexcept(), isnan()
88
89       The Base Definitions volume of POSIX.1‐2008, Section 4.19, Treatment of
90       Error Conditions for Mathematical Functions, <math.h>, <stdio.h>
91
93       Portions of this text are reprinted and reproduced in  electronic  form
94       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
95       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
96       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
97       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
98       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
99       event of any discrepancy between this version and the original IEEE and
100       The  Open Group Standard, the original IEEE and The Open Group Standard
101       is the referee document. The original Standard can be  obtained  online
102       at http://www.unix.org/online.html .
103
104       Any  typographical  or  formatting  errors that appear in this page are
105       most likely to have been introduced during the conversion of the source
106       files  to  man page format. To report such errors, see https://www.ker
107       nel.org/doc/man-pages/reporting_bugs.html .
108
109
110
111IEEE/The Open Group                  2013                             SQRT(3P)
Impressum