Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference (Volume 7 of 9): Section 3: Library Functions (N-Z) > r

rint(3M)

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

rint(), nearbyint() — round to nearest int function

SYNOPSIS

#include <math.h>

double rint(double x);

double nearbyint(double x);

DESCRIPTION

rint() and nearbyint() return the integer (represented as a double precision number) nearest x according to the current rounding direction mode. These functions meet the requirement of the IEEE-754 standard for an operation that rounds to integer in floating-point format.

The two functions are identical except that rint() raises the inexact exception, while nearbyint() does not.

In the default rounding direction (round to nearest), rint(x) is the integer nearest x with the additional stipulation that if |rint(x) -x|=1/2, then rint(x) is even. (The same statement applies to nearbyint(x).)

If the current rounding direction is toward negative infinity, rint() and nearbyint() are identical to floor(). If the current rounding direction is toward positive infinity, rint() and nearbyint() are identical to ceil().

The ISO/ANSI C committee has approved the rint() and nearbyint() functions for inclusion in the C9X draft standard.

To use these functions, compile either with the default -Ae option or with the -Aa and -D_HPUX_SOURCE options. Make sure your program includes <math.h>. Link in the math library by specifying -lm on the compiler or linker command line.

RETURN VALUE

If x is ±INFINITY, the rint() and nearbyint() functions return ±INFINITY respectively.

If x is NaN, the rint() and nearbyint() functions return NaN.

ERRORS

No errors are defined.

STANDARDS CONFORMANCE

rint(): XPG4.2, IEEE-754

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2000 Hewlett-Packard Development Company, L.P.