What is nearbyintl in C?
The nearbyintl function is a C library function that rounds the argument’s value to the nearest integer value.
To use the nearbyintl function, we need to include the math.h header file, as shown below:
#include <math.h>
Syntax
The nearbyintl function takes a single argument and returns a single value. It is declared as follows:
Parameters
The nearbyintl function takes a single argument of the long double type.
Return Value
The nearbyintl function returns the nearest integer in the long double type format.
Example
The code below shows the use of the nearbyintl function in C:
#include <stdio.h>#include <math.h>int main() {//Declare xlong double x = 3.6890;//Call nearbyintl functionlong double ans = nearbyintl(x);//Display the resultprintf ("The nearest integer is: %Lf\n", ans);return 0;}
Free Resources
Copyright ©2026 Educative, Inc. All rights reserved