C++ Math llrint()

Last Updated : 22 May 2026

Math llrint() Function

In C++, the llrint() function is defined in the <cmath> or <math.h> header file and is used to round a floating-point value according to the current rounding mode and return the result as a long long int. The rounding mode can be controlled using the fesetround() function from the <cfenv> header file.

The llrint() function supports float, double, and long double values. It is commonly used where rounded long long integer values are required.

Syntax

It has the following syntax.

Parameter

x: The value which is to be rounded.

Return value

It returns the rounded value of 'x' and the return type of the value is long long int.

Examples of the List lrint() Function

Here, we are going to discuss several examples to demonstrate the List lrint() Function Function.

Example 1: Round a Floating-Point Value Upward Using llrint()

This example demonstrates how the llrint() function rounds a floating-point value upward using the upward rounding mode.

Output:

Value of x is :5.3
Rounded value of x is :6   

Example 2: Round a Floating-Point Value Downward Using llrint()

This example demonstrates how the llrint() function rounds a floating-point value downward using the downward rounding mode.

Output:

Value of x is :7.9
Rounded value of x is :7

Example 3: Use llrint() with an Integer Value

This example demonstrates how the llrint() function behaves when the input value is already an integer. In this case, the same value is returned as a long long integer.

Output:

Value of x is : 30
Rounded value of x is : 30