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

NAME

12       sqrt, sqrtf, sqrtl — square root function
13

SYNOPSIS

15       #include <math.h>
16
17       double sqrt(double x);
18       float sqrtf(float x);
19       long double sqrtl(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 square root of their argument x, √x.
28
29       An  application  wishing to check for error situations should set errno
30       to zero and  call  feclearexcept(FE_ALL_EXCEPT)  before  calling  these
31       functions. On return, if errno is non-zero or fetestexcept(FE_INVALID |
32       FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero,  an  error  has
33       occurred.
34

RETURN VALUE

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

ERRORS

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

EXAMPLES

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

APPLICATION USAGE

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

RATIONALE

78       None.
79

FUTURE DIRECTIONS

81       None.
82

SEE ALSO

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