Rate This Document
Findability
Accuracy
Completeness
Readability

lrint

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

Interface Definition

C interface:

long int lrintf(float x);

long int lrint(double x);

long int llrintl(long double x);

Parameters

Parameter

Type

Description

Input/Output

x

  • For lrintf, x is of single-precision floating-point type.
  • For lrint, x is of double-precision floating-point type.
  • For llrintl, 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("lrint(0.0) = %lld\n", lrint(0.0));
    printf("lrint(-0.0) = %lld\n", lrint(-0.0));
    printf("lrint(1.0) = %lld\n", lrint(1.0));
    printf("lrint(1.4) = %lld\n", lrint(1.4));
    printf("lrint(1.5) = %lld\n", lrint(1.5));
    printf("lrint(-3.0) = %lld\n", lrint(-3.0));
    printf("lrint(-3.4) = %lld\n", lrint(-3.4));
    printf("lrint(-3.5) = %lld\n", lrint(-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
     * */