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
21

DESCRIPTION

23       These functions shall compute the square  root  of  their  argument  x,
24       sqrt(x).
25
26       An  application  wishing to check for error situations should set errno
27       to zero and  call  feclearexcept(FE_ALL_EXCEPT)  before  calling  these
28       functions.   On return, if errno is non-zero or fetestexcept(FE_INVALID
29       | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error  has
30       occurred.
31

RETURN VALUE

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

ERRORS

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

EXAMPLES

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

APPLICATION USAGE

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

RATIONALE

76       None.
77

FUTURE DIRECTIONS

79       None.
80

SEE ALSO

82       feclearexcept(), fetestexcept(), isnan(), the Base  Definitions  volume
83       of  IEEE Std 1003.1-2001,  Section  4.18, Treatment of Error Conditions
84       for Mathematical Functions, <math.h>, <stdio.h>
85
87       Portions of this text are reprinted and reproduced in  electronic  form
88       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
89       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
90       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
91       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
92       event of any discrepancy between this version and the original IEEE and
93       The Open Group Standard, the original IEEE and The Open Group  Standard
94       is  the  referee document. The original Standard can be obtained online
95       at http://www.opengroup.org/unix/online.html .
96
97
98
99IEEE/The Open Group                  2003                             SQRT(3P)
Impressum