logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

sqrt.3p (3663B)


  1. '\" et
  2. .TH SQRT "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .EQ
  11. delim $$
  12. .EN
  13. .SH NAME
  14. sqrt,
  15. sqrtf,
  16. sqrtl
  17. \(em square root function
  18. .SH SYNOPSIS
  19. .LP
  20. .nf
  21. #include <math.h>
  22. .P
  23. double sqrt(double \fIx\fP);
  24. float sqrtf(float \fIx\fP);
  25. long double sqrtl(long double \fIx\fP);
  26. .fi
  27. .SH DESCRIPTION
  28. The functionality described on this reference page is aligned with the
  29. ISO\ C standard. Any conflict between the requirements described here and the
  30. ISO\ C standard is unintentional. This volume of POSIX.1\(hy2017 defers to the ISO\ C standard.
  31. .P
  32. These functions shall compute the square root of their argument
  33. .IR x ,
  34. $sqrt {x}$.
  35. .P
  36. An application wishing to check for error situations should set
  37. .IR errno
  38. to zero and call
  39. .IR feclearexcept (FE_ALL_EXCEPT)
  40. before calling these functions. On return, if
  41. .IR errno
  42. is non-zero or \fIfetestexcept\fR(FE_INVALID | FE_DIVBYZERO |
  43. FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has occurred.
  44. .SH "RETURN VALUE"
  45. Upon successful completion, these functions shall return the square
  46. root of
  47. .IR x .
  48. .P
  49. For finite values of
  50. .IR x
  51. < \-0, a domain error shall occur, and
  52. either a NaN (if supported), or
  53. an implementation-defined value shall be returned.
  54. .P
  55. If
  56. .IR x
  57. is NaN, a NaN shall be returned.
  58. .P
  59. If
  60. .IR x
  61. is \(+-0 or +Inf,
  62. .IR x
  63. shall be returned.
  64. .P
  65. If
  66. .IR x
  67. is \-Inf, a domain error shall occur, and a NaN shall be returned.
  68. .SH ERRORS
  69. These functions shall fail if:
  70. .IP "Domain\ Error" 12
  71. The finite value of
  72. .IR x
  73. is < \-0,
  74. or
  75. .IR x
  76. is \-Inf.
  77. .RS 12
  78. .P
  79. If the integer expression (\fImath_errhandling\fR & MATH_ERRNO) is
  80. non-zero, then
  81. .IR errno
  82. shall be set to
  83. .BR [EDOM] .
  84. If the integer expression (\fImath_errhandling\fR & MATH_ERREXCEPT) is
  85. non-zero, then the invalid floating-point exception shall be raised.
  86. .RE
  87. .LP
  88. .IR "The following sections are informative."
  89. .SH EXAMPLES
  90. .SS "Taking the Square Root of 9.0"
  91. .sp
  92. .RS 4
  93. .nf
  94. #include <math.h>
  95. \&...
  96. double x = 9.0;
  97. double result;
  98. \&...
  99. result = sqrt(x);
  100. .fi
  101. .P
  102. .RE
  103. .SH "APPLICATION USAGE"
  104. On error, the expressions (\fImath_errhandling\fR & MATH_ERRNO) and
  105. (\fImath_errhandling\fR & MATH_ERREXCEPT) are independent of each
  106. other, but at least one of them must be non-zero.
  107. .SH RATIONALE
  108. None.
  109. .SH "FUTURE DIRECTIONS"
  110. None.
  111. .SH "SEE ALSO"
  112. .IR "\fIfeclearexcept\fR\^(\|)",
  113. .IR "\fIfetestexcept\fR\^(\|)",
  114. .IR "\fIisnan\fR\^(\|)"
  115. .P
  116. The Base Definitions volume of POSIX.1\(hy2017,
  117. .IR "Section 4.20" ", " "Treatment of Error Conditions for Mathematical Functions",
  118. .IR "\fB<math.h>\fP",
  119. .IR "\fB<stdio.h>\fP"
  120. .\"
  121. .SH COPYRIGHT
  122. Portions of this text are reprinted and reproduced in electronic form
  123. from IEEE Std 1003.1-2017, Standard for Information Technology
  124. -- Portable Operating System Interface (POSIX), The Open Group Base
  125. Specifications Issue 7, 2018 Edition,
  126. Copyright (C) 2018 by the Institute of
  127. Electrical and Electronics Engineers, Inc and The Open Group.
  128. In the event of any discrepancy between this version and the original IEEE and
  129. The Open Group Standard, the original IEEE and The Open Group Standard
  130. is the referee document. The original Standard can be obtained online at
  131. http://www.opengroup.org/unix/online.html .
  132. .PP
  133. Any typographical or formatting errors that appear
  134. in this page are most likely
  135. to have been introduced during the conversion of the source files to
  136. man page format. To report such errors, see
  137. https://www.kernel.org/doc/man-pages/reporting_bugs.html .