In this C++ tutorial, you will learn how to round a given number to nearest long long int value using llround() function of cmath, with syntax and examples.

C++ llround()

C++ llround() rounds given value to nearest long long int.


The syntax of C++ llround() is



xA value of type float, double, long double, or integral type.


The function returns long long int value.

The synopsis of llround() function is

long long int llround(float x);
long long int llround(double x);
long long int llround(long double x);

llround() is a function of cmath library. Include cmath library at the start of program, if using llround() function.



In this example, we

C++ Program

#include <iostream>
using namespace std;

int main() {
    double x;
    cout << "Enter a number : ";
    cin >> x;
    double result = llround(x);
    cout << "llround(" << x << ") : " << result << endl;


Enter a number : 25.3685
llround(25.3685) : 25
Program ended with exit code: 0
Enter a number : -2.36
llround(-2.36) : -2
Program ended with exit code: 0


In this C++ Tutorial, we learned the syntax of C++ llround(), and how to use this function to find the nearest long long int of given value, with the help of examples.