hypot, hypotf, hypotl, _hypot, _hypotf, _hypotl

Calcula la hipotenusa.

Sintaxis

double hypot(
   double x,
   double y
);
float hypotf(
   float x,
   float y
);
long double hypotl(
   long double x,
   long double y
);
double _hypot(
   double x,
   double y
);
float _hypotf(
   float x,
   float y
);
long double _hypotl(
   long double x,
   long double y
);
#define hypotf(X, Y) // Requires C11 or higher

Parámetros

x, y
Valores de punto flotante.

Valor devuelto

Si se realiza correctamente, hypot devuelve la longitud de la hipotenusa. Si se produce un desbordamiento, hypot devuelve INF (infinito) y la variable errno se establece en ERANGE. Puede utilizar _matherr para modificar el control de errores.

Para obtener más información sobre los códigos de retorno, vea errno, _doserrno, _sys_errlist y _sys_nerr.

Comentarios

Las funciones hypot calculan la longitud de la hipotenusa de un triángulo rectángulo, dada la longitud de los lados x e y (es decir, la raíz cuadrada de x2 + y2).

Las versiones de las funciones que tienen un carácter de subrayado inicial se proporcionan por compatibilidad con estándares anteriores. Su comportamiento es idéntico al de las versiones sin carácter de subrayado inicial. Se recomienda el uso de las versiones sin carácter de subrayado inicial para código nuevo.

Si usa la macro <tgmath.h>hypot(), el tipo del argumento determina qué versión de la función se selecciona. Consulte Matemáticas de tipo genérico para obtener más información.

De manera predeterminada, el estado global de esta función está limitado a la aplicación. Para cambiar este comportamiento, consulte Estado global en CRT.

Requisitos

Routine Encabezado necesario
hypot, hypotf, hypotl, _hypot, _hypotf, _hypotl <math.h>
hypotMacro <tgmath.h>

Para obtener más información sobre compatibilidad, consulte Compatibilidad.

Ejemplo

// crt_hypot.c
// This program prints the hypotenuse of a right triangle.

#include <math.h>
#include <stdio.h>

int main( void )
{
   double x = 3.0, y = 4.0;

   printf( "If a right triangle has sides %2.1f and %2.1f, "
           "its hypotenuse is %2.1f\n", x, y, _hypot( x, y ) );
}
If a right triangle has sides 3.0 and 4.0, its hypotenuse is 5.0

Consulte también

Compatibilidad con matemáticas y punto flotante
_cabs
_matherr