std::hypot
Da cppreference.com.
![]() | Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate. La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
Elemento definito nell'header <cmath> | ||
float hypot(float x, float y ); | (1) | (dal C++11) |
double hypot(double x, double y ); | (2) | (dal C++11) |
longdouble hypot(longdouble x, longdouble y ); | (3) | (dal C++11) |
Promoted hypot( Arithmetic x, Arithmetic y ); | (4) | (dal C++11) |
Calcola la radice quadrata della somma dei quadrati di
4) x
e y
, senza troppopieno indebito o underflow intermedi del calcolo. Questa è la lunghezza dell'ipotenusa di un triangolo rettangolo con lati di lunghezza x
e y
, o la distanza del punto (x,y)
dall'origine (0,0)
, o la grandezza di un x+iy
numero complessoOriginal:
Computes the square root of the sum of the squares of
x
and y
, without undue overflow or underflow at intermediate stages of the computation. This 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 text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Se un qualsiasi argomento è di tipo integrale, il cast double. Se qualsiasi altro argomento è longdouble, quindi il tipo di ritorno è longdouble, altrimenti è double.
Original:
If any argument has integral type, it is cast to double. If any other argument is longdouble, then the return type is longdouble, otherwise it is double.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Indice |
[modifica]Parametri
x | - | valore in virgola mobile Original: floating point value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
y | - | valore in virgola mobile Original: floating point value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[modifica]Valore di ritorno
L'ipotenusa di un triangolo rettangolo, √x2
+y2
.
+y2
.
Original:
The hypotenuse of a right-angled triangle, √x2
+y2
.
+y2
.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[modifica]Eccezioni
Se il risultato overflow, un errore di campo si può verificare e FE_OVERFLOW può essere sollevata.
Original:
If the result overflows, a range error may occur and FE_OVERFLOW may be raised.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Se il risultato è subnormale, un errore può verificarsi underflow e FE_UNDERFLOW può essere sollevata.
Original:
If the result is subnormal, an underflow error may occur and FE_UNDERFLOW may be raised.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[modifica]Note
Strategia di attuazione tipico è quello di calcolare l'equivalente di u√1+(
)2
dove
v |
u |
dove
u
è std::max(x,y) e v
è std::min(x,y).Original:
Typical implementation strategy is to calculate an equivalent of u√1+(
)2
where
v |
u |
where
u
is std::max(x,y) and v
is std::min(x,y).The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[modifica]Esempio
#include <cmath>#include <utility>#include <iostream> std::pair<double, double> cartesian_to_polar(double x, double y){return{std::hypot(x, y), std::atan2(y,x)};} int main(){std::pair<double, double> polar = cartesian_to_polar(1, 1);std::cout<<"(1,1) cartesian is ("<< polar.first<<","<< polar.second<<") polar\n";}
Output:
(1,1) cartesian is (1.41421,0.785398) polar
[modifica]Vedi anche
calcola la radice quadrata (√x) Original: computes square root (√x) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione) | |
solleva un numero alla potenza data (xy) Original: raises a number to the given power (xy) The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione) | |
restituisce la grandezza di un numero complesso Original: returns the magnitude of a complex number The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione di modello) |