std::hypot, std::hypotf, std::hypotl
| Defined in header <cmath>
|
||
| (1) | ||
float hypot ( float x, float y ); double hypot ( double x, double y ); |
(since C++11) (until C++23) |
|
| /*floating-point-type*/ hypot ( /*floating-point-type*/ x, |
(since C++23) (constexpr since C++26) |
|
float hypotf( float x, float y ); |
(2) | (since C++11) (constexpr since C++26) |
long double hypotl( long double x, long double y ); |
(3) | (since C++11) (constexpr since C++26) |
| (4) | ||
float hypot ( float x, float y, float z ); double hypot ( double x, double y, double z ); |
(since C++17) (until C++23) |
|
| /*floating-point-type*/ hypot ( /*floating-point-type*/ x, |
(since C++23) (constexpr since C++26) |
|
| Defined in header <cmath>
|
||
template< class Arithmetic1, Arithmetic2 > /*common-floating-point-type*/ |
(A) | (since C++11) (constexpr since C++26) |
| template< class Arithmetic1, Arithmetic2, Arithmetic3 > /*common-floating-point-type*/ |
(B) | (since C++17) |
std::hypot for all cv-unqualified floating-point types as the type of the parameters x and y.(since C++23)std::hypot for all cv-unqualified floating-point types as the type of the parameters x, y and z.(since C++23)The value computed by the two-argument version of this function is the length of the hypotenuse of a right-angled triangle with sides of length x and y, or the distance of the point (x,y) from the origin (0,0), or the magnitude of a complex number x+iy.
The value computed by the three-argument version of this function is the distance of the point (x,y,z) from the origin (0,0,0).
Contents |
[edit] Parameters
| x, y, z | - | floating-point or integer values |
[edit] Return value
+y2
, is returned.
+y2
+z2
, is returned.
If a range error due to overflow occurs, +HUGE_VAL, +HUGE_VALF, or +HUGE_VALL is returned.
If a range error due to underflow occurs, the correct result (after rounding) is returned.
[edit] Error handling
Errors are reported as specified in math_errhandling.
If the implementation supports IEEE floating-point arithmetic (IEC 60559),
- std::hypot(x, y), std::hypot(y, x), and std::hypot(x, -y) are equivalent.
- if one of the arguments is ±0, std::hypot(x, y) is equivalent to std::fabs called with the non-zero argument.
- if one of the arguments is ±∞, std::hypot(x, y) returns +∞ even if the other argument is NaN.
- otherwise, if any of the arguments is NaN, NaN is returned.
[edit] Notes
Implementations usually guarantee precision of less than 1