◐ Shell
clean mode source ↗

std::hypot - cppreference.com

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.

Click here for the English version of this page

<metanoindex/>

<tbody> </tbody>

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)

long double hypot( long double x, long double y );

(3) (dal C++11)

Promoted hypot( Arithmetic x, Arithmetic y );

(4) (dal C++11)

Calcola la radice quadrata della somma dei quadrati di 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 complesso

Original:

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.

4)

Se un qualsiasi argomento è di tipo integrale, il cast double. Se qualsiasi altro argomento è long double, quindi il tipo di ritorno è long double, altrimenti è double.

Original:

If any argument has integral type, it is cast to double. If any other argument is long double, then the return type is long double, 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.

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.

Valore di ritorno

L'ipotenusa di un triangolo rettangolo, x2
+y2
.

Original:

The hypotenuse of a right-angled triangle, x2
+y2
.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

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.

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.

Note

Strategia di attuazione tipico è quello di calcolare l'equivalente di u1+()2
dove u è std::max(x,y) e v è std::min(x,y).

Original:

Typical implementation strategy is to calculate an equivalent of u1+()2
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.

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

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) [modifica]

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) [modifica]

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) [modifica]