C Tutorial/math.h/lround

Материал из C\C++ эксперт
Перейти к: навигация, поиск

lround

Item Value Header file math.h Declaration long int lroundf(float arg);long int lround(double arg);long int lroundl(long double arg); Return returns the value of arg rounded to the nearest long integer.

Values precisely between two values, such as 3.5, are rounded up.


<source lang="cpp">#include <math.h>

 #include <stdio.h>
 int main(void)
 {
   double val = 1.0;
   do {
     printf("%f %f\n", val, lround (val));
     val++;
   } while (val<11.0);
   return 0;
 }</source>