1sqrt(3M) Mathematical Library Functions sqrt(3M)
2
3
4
6 sqrt, sqrtf, sqrtl - square root function
7
9 c99 [ flag... ] file... -lm [ library... ]
10 #include <math.h>
11
12 double sqrt(double x);
13
14
15 float sqrtf(float x);
16
17
18 long double sqrtl(long double x);
19
20
22 These functions compute the square root of their argument x.
23
25 Upon successful completion, these functions return the square root of
26 x.
27
28
29 For finite values of x < −0, a domain error occurs and either a NaN (if
30 supported) or an implementation-defined value is returned.
31
32
33 If x is NaN, a NaN is returned.
34
35
36 If x is ±0 or +Inf, x is returned.
37
38
39 If x is −Inf, a domain error occurs and a NaN is returned.
40
42 These functions will fail if:
43
44 Domain Error The finite value of x is < −0 or x is −Inf.
45
46 If the integer expression (math_errhandling &
47 MATH_ERREXCEPT) is non-zero, the invalid floating-point
48 exception is raised.
49
50 The sqrt() function sets errno to EDOM if the value of
51 x is negative.
52
53
55 An application wanting to check for exceptions should call feclearex‐
56 cept(FE_ALL_EXCEPT) before calling these functions. On return, if
57 fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is
58 non-zero, an exception has been raised. An application should either
59 examine the return value or check the floating point exception flags to
60 detect exceptions.
61
62
63 An application can also set errno to 0 before calling sqrt(). On
64 return, if errno is non-zero, an error has occurred. The sqrtf() and
65 sqrtl() functions do not set errno.
66
68 See attributes(5) for descriptions of the following attributes:
69
70
71
72
73 ┌─────────────────────────────┬─────────────────────────────┐
74 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
75 ├─────────────────────────────┼─────────────────────────────┤
76 │Interface Stability │Standard │
77 ├─────────────────────────────┼─────────────────────────────┤
78 │MT-Level │MT-Safe │
79 └─────────────────────────────┴─────────────────────────────┘
80
82 feclearexcept(3M), fetestexcept(3M), isnan(3M), math.h(3HEAD),
83 attributes(5), standards(5)
84
85
86
87SunOS 5.11 12 Jul 2006 sqrt(3M)