Rate This Document
Findability
Accuracy
Completeness
Readability

lround

Return the rounded value in long int format based on the current rounding mode.

Interface Definition

C interface:

long int lroundf(float x);

long int lround(double x);

long int llroundl(long double x);

Parameters

Parameter

Type

Description

Input/Output

x

  • For lroundf, x is of single-precision floating-point type.
  • For lround, x is of double-precision floating-point type.
  • For llroundl, x is of long double-precision floating-point type.

Floating-point value of the input data.

Input

Return Value

The rounded value of x is returned. x ∈ (-inf, inf)

Dependency

C: "km.h"

Example

C interface:
    // typical usage
    printf("lround(0.0) = %ld\n", lround(0.0));
    printf("lround(-0.0) = %ld\n", lround(-0.0));
    printf("lround(1.0) = %ld\n", lround(1.0));
    printf("lround(1.4) = %ld\n", lround(1.4));
    printf("lround(1.5) = %ld\n", lround(1.5));
    printf("lround(-3.0) = %ld\n", lround(-3.0));
    printf("lround(-3.4) = %ld\n", lround(-3.4));
    printf("lround(-3.5) = %ld\n", lround(-3.5));

result
    /* 
     * lrint(0.0) = 0
     * lrint(-0.0) = 0
     * lrint(1.0) = 1
     * lrint(1.4) = 1
     * lrint(1.5) = 2
     * lrint(-3.0) = -3
     * lrint(-3.4) = -3
     * lrint(-3.0) = -4
     * */