[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 1

lround, lroundf, or lroundl Subroutine

Purpose

Rounds to the nearest integer value.

Syntax

#include <math.h>

long lround (x)
double x;

long lroundf (x)
float x;

long lroundl (x)
long double x;

Description

The lround, lroundf, and lroundl subroutines round the x parameter to the nearest integer value, rounding halfway cases away from zero, regardless of the current rounding direction.

An application wishing to check for error situations should set the errno global variable to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these subroutines. Upon return, if errno is nonzero or fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is nonzero, an error has occurred.

Parameters

x Specifies the value to be rounded.

Return Values

Upon successful completion, the lround, lroundf, and lroundl subroutines return the rounded integer value.

If x is NaN, a domain error occurs and an unspecified value is returned.

If x is +Inf, a domain error occurs and an unspecified value is returned.

If x is -Inf, a domain error occurs and an unspecified value is returned.

If the correct value is positive and too large to represent as a long, a domain error occurs and an unspecified value is returned.

If the correct value is negative and too large to represent as a long, a domain error occurs and an unspecified value is returned.

Related Information

feclearexcept Subroutine, fetestexcept Subroutine, and llround, llroundf, or llroundl Subroutine.

math.h in AIX 5L Version 5.2 Files Reference.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]