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.
Syntax
The syntax of C++ llround() is
llround(x)
where
Parameter | Description |
---|---|
x | A value of type float, double, long double, or integral type. |
Returns
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.
ADVERTISEMENT
Example
In this example, we
C++ Program
#include <iostream> #include<cmath> using namespace std; int main() { double x; cout << "Enter a number : "; cin >> x; double result = llround(x); cout << "llround(" << x << ") : " << result << endl; }
Output
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
Conclusion
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.