lround, lroundf, lroundl, llround, llroundf, llroundl
Redondea un valor de punto flotante al entero más cercano.
long lround(
double x
);
long lround(
float x
); // C++ only
long lround(
long double x
); // C++ only
long lroundf(
float x
);
long lroundl(
long double x
);
long long llround(
double x
);
long long llround(
float x
); // C++ only
long long llround(
long double x
); // C++ only
long long llroundf(
float x
);
long long llroundl(
long double x
);
Parámetros
- x
El valor de punto flotante que se debe redondear.
Valor devuelto
Las funciones lround y llround devuelven el entero más próximo long o long long a x. Los valores intermedios se redondean desde de cero, independientemente del valor de modo de redondeo de punto flotante. No se devuelve ningún error.
Entrada |
Excepción SEH |
Excepción de Matherr |
---|---|---|
± QNAN, IND |
ninguno |
_DOMAIN |
Comentarios
Como C++ permite las sobrecargas, puede llamar a las sobrecargas de lround o llround que toman y devuelven los valores float y long double. En un programa de C, lround y llround siempre toman y devuelven double.
Requisitos
Rutina |
Encabezado necesario |
---|---|
lround, lroundf, lroundl, llround, llroundf, llroundl |
<math.h> |
Para obtener información adicional de compatibilidad, vea Compatibilidad.
Ejemplo
// crt_lround.c
// Build with: cl /W3 /Tc crt_lround.c
// This example displays the rounded results of
// the floating-point values 2.499999, -2.499999,
// 2.8, -2.8, 3.5 and -3.5.
#include <math.h>
#include <stdio.h>
int main( void )
{
double x = 2.499999;
float y = 2.8f;
long double z = 3.5;
printf("lround(%f) is %d\n", x, lround(x));
printf("lround(%f) is %d\n", -x, lround(-x));
printf("lroundf(%f) is %d\n", y, lroundf(y));
printf("lroundf(%f) is %d\n", -y, lroundf(-y));
printf("lroundl(%Lf) is %d\n", z, lroundl(z));
printf("lroundl(%Lf) is %d\n", -z, lroundl(-z));
}
Equivalente en .NET Framework
Vea también
Referencia
Compatibilidad con el punto flotante