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

hypot.3p (4684B)


  1. '\" et
  2. .TH HYPOT "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. .SH NAME
  11. hypot,
  12. hypotf,
  13. hypotl
  14. \(em Euclidean distance function
  15. .SH SYNOPSIS
  16. .LP
  17. .nf
  18. #include <math.h>
  19. .P
  20. double hypot(double \fIx\fP, double \fIy\fP);
  21. float hypotf(float \fIx\fP, float \fIy\fP);
  22. long double hypotl(long double \fIx\fP, long double \fIy\fP);
  23. .fi
  24. .SH DESCRIPTION
  25. The functionality described on this reference page is aligned with the
  26. ISO\ C standard. Any conflict between the requirements described here and the
  27. ISO\ C standard is unintentional. This volume of POSIX.1\(hy2017 defers to the ISO\ C standard.
  28. .P
  29. These functions shall compute the value of the square root of
  30. .IR x \s-3\u2\d\s+3+\c
  31. .IR y \s-3\u2\d\s+3
  32. without undue overflow or underflow.
  33. .P
  34. An application wishing to check for error situations should set
  35. .IR errno
  36. to zero and call
  37. .IR feclearexcept (FE_ALL_EXCEPT)
  38. before calling these functions. On return, if
  39. .IR errno
  40. is non-zero or \fIfetestexcept\fR(FE_INVALID | FE_DIVBYZERO |
  41. FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has occurred.
  42. .SH "RETURN VALUE"
  43. Upon successful completion, these functions shall return the length of
  44. the hypotenuse of a right-angled triangle with sides of length
  45. .IR x
  46. and
  47. .IR y .
  48. .P
  49. If the correct value would cause overflow, a range error shall occur
  50. and
  51. \fIhypot\fR(),
  52. \fIhypotf\fR(),
  53. and
  54. \fIhypotl\fR()
  55. shall return the value of the macro HUGE_VAL, HUGE_VALF, and HUGE_VALL,
  56. respectively.
  57. .P
  58. If
  59. .IR x
  60. or
  61. .IR y
  62. is \(+-Inf, +Inf shall be returned (even if one of
  63. .IR x
  64. or
  65. .IR y
  66. is NaN).
  67. .P
  68. If
  69. .IR x
  70. or
  71. .IR y
  72. is NaN, and the other is not \(+-Inf, a NaN shall be returned.
  73. .P
  74. If both arguments are subnormal and the correct result is subnormal,
  75. a range error may occur and the correct result shall be returned.
  76. .SH ERRORS
  77. These functions shall fail if:
  78. .IP "Range\ Error" 12
  79. The result overflows.
  80. .RS 12
  81. .P
  82. If the integer expression (\fImath_errhandling\fR & MATH_ERRNO) is
  83. non-zero, then
  84. .IR errno
  85. shall be set to
  86. .BR [ERANGE] .
  87. If the integer expression (\fImath_errhandling\fR & MATH_ERREXCEPT) is
  88. non-zero, then the overflow floating-point exception shall be raised.
  89. .RE
  90. .P
  91. These functions may fail if:
  92. .IP "Range\ Error" 12
  93. The result underflows.
  94. .RS 12
  95. .P
  96. If the integer expression (\fImath_errhandling\fR & MATH_ERRNO) is
  97. non-zero, then
  98. .IR errno
  99. shall be set to
  100. .BR [ERANGE] .
  101. If the integer expression (\fImath_errhandling\fR & MATH_ERREXCEPT) is
  102. non-zero, then the underflow floating-point exception shall be raised.
  103. .RE
  104. .LP
  105. .IR "The following sections are informative."
  106. .SH EXAMPLES
  107. See the EXAMPLES section in
  108. \fIatan2\fR().
  109. .SH "APPLICATION USAGE"
  110. \fIhypot\fR(\fIx\fR,\fIy\fR), \fIhypot\fR(\fIy\fR,\fIx\fR), and
  111. \fIhypot\fR(\fIx\fR, \-\fIy\fR) are equivalent.
  112. .P
  113. \fIhypot\fR(\fIx\fR, \(+-0) is equivalent to \fIfabs\fR(\fIx\fR).
  114. .P
  115. Underflow only happens when both
  116. .IR x
  117. and
  118. .IR y
  119. are subnormal and the (inexact) result is also subnormal.
  120. .P
  121. These functions take precautions against overflow during intermediate
  122. steps of the computation.
  123. .P
  124. On error, the expressions (\fImath_errhandling\fR & MATH_ERRNO) and
  125. (\fImath_errhandling\fR & MATH_ERREXCEPT) are independent of each
  126. other, but at least one of them must be non-zero.
  127. .SH RATIONALE
  128. None.
  129. .SH "FUTURE DIRECTIONS"
  130. None.
  131. .SH "SEE ALSO"
  132. .IR "\fIatan2\fR\^(\|)",
  133. .IR "\fIfeclearexcept\fR\^(\|)",
  134. .IR "\fIfetestexcept\fR\^(\|)",
  135. .IR "\fIisnan\fR\^(\|)",
  136. .IR "\fIsqrt\fR\^(\|)"
  137. .P
  138. The Base Definitions volume of POSIX.1\(hy2017,
  139. .IR "Section 4.20" ", " "Treatment of Error Conditions for Mathematical Functions",
  140. .IR "\fB<math.h>\fP"
  141. .\"
  142. .SH COPYRIGHT
  143. Portions of this text are reprinted and reproduced in electronic form
  144. from IEEE Std 1003.1-2017, Standard for Information Technology
  145. -- Portable Operating System Interface (POSIX), The Open Group Base
  146. Specifications Issue 7, 2018 Edition,
  147. Copyright (C) 2018 by the Institute of
  148. Electrical and Electronics Engineers, Inc and The Open Group.
  149. In the event of any discrepancy between this version and the original IEEE and
  150. The Open Group Standard, the original IEEE and The Open Group Standard
  151. is the referee document. The original Standard can be obtained online at
  152. http://www.opengroup.org/unix/online.html .
  153. .PP
  154. Any typographical or formatting errors that appear
  155. in this page are most likely
  156. to have been introduced during the conversion of the source files to
  157. man page format. To report such errors, see
  158. https://www.kernel.org/doc/man-pages/reporting_bugs.html .