hypot, hypotf, hypotl, _hypot, _hypotf, _hypotl
Calcula la hipotenusa.
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
);
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.
Requisitos
Rutina |
Encabezado necesario |
---|---|
hypot, hypotf, hypotl, _hypot, _hypotf, _hypotl |
<math.h> |
Para obtener más información de compatibilidad, vea 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 ) );
}
Equivalente en .NET Framework
No es aplicable Para llamar a la función estándar de C, use PInvoke. Para obtener más información, vea Ejemplos de invocación de plataforma.