HPlogo HP-UX Reference > L

lround(3M)

HP-UX 11i Version 2: December 2007 Update
» 

Technical documentation

 » Table of Contents

 » Index

NAME

lround(), lroundf(), lroundl(), lroundw(), lroundq() — round to long int functions

SYNOPSIS

#include <math.h>

long int lround(double x);

Itanium(R)-based System Only

long int lroundf(float x);

long int lroundl(long double x);

long int lroundw(extended x);

long int lroundq(quad x);

DESCRIPTION

lround() rounds its argument to the nearest integral value. An argument exactly halfway between two integers is rounded away from zero, regardless of the current rounding direction. Rounding away from zero also applies to the functions, round and llround.

lround() is equivalent to llround(), except that it rounds to long int instead of long long.

Itanium-based System Only

lroundf() is a float version of lround(); it takes a float argument.

lroundl() is a long double version of lround(); it takes a long double argument.

lroundw() is an extended version of lround(); it takes an extended argument.

lroundq() is equivalent to lroundl() on HP-UX systems.

USAGE

To use these functions, compile either with the default -Ae option or with the -Aa and -D_HPUX_SOURCE options.

To use (for Itanium-based systems) lroundw() or lroundq(), compile also with the -fpwidetypes option.

Make sure your program includes <math.h>. Link in the math library by specifying -lm on the compiler or linker command line.

For more information, see the HP-UX Floating-Point Guide.

RETURN VALUE

If the rounded value is outside the range of long int, the numeric result is the maximum or minimum long int value and the invalid floating-point exception is raised. On Itanium-based systems, if the rounded value is outside the range of long int, the numeric result is the minimum long int value.

When lround() raises no other floating-point exception and the result differs from the argument, the function may raise the inexact floating-point exception.

ERRORS

No errors are defined.

STANDARDS CONFORMANCE

lround(), lroundf(), lroundl() : ISO/IEC C99 (including Annex F, ``IEC 60559 floating-point arithmetic'')