llround - C math.h

C examples for math.h:llround

Type

function

From

<cmath>
<ctgmath>
<math.h>

Description

Returns the integer value that is nearest in value to x, with halfway cases rounded away from zero.

The rounded value is returned as a value of type long long int.

Prototype

long long int llround  (double x);
long long int llroundf (float x);
long long int llroundl (long double x);
long long int llround (float x);
long long int llround (long double x);
long long int llround (T x);           

Parameters

Parameter Description
x Value to round.

Return Value

The value of x rounded to the nearest integral, casted to a value of type long long int.

Example

Demo Code

#include <stdio.h>
#include <math.h> /* lround */

int main ()//from ww  w  . jav a 2s  . co  m
{
  printf ( "%lld\n", llround(2.1) );
  printf ( "%lld\n", llround(3.9) );
  printf ( "%lld\n", llround(-2.1) );
  printf ( "%lld\n", llround(-3.9) );
  return 0;
}

Related Tutorials