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 > N

nextafter(3M)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

nextafter(), nextafterf(), nextafterl(), nextafterw(), nextafterq(), nexttoward(), nexttowardf(), nexttowardl(), nexttowardw(), nexttowardq() — next representable floating-point values

SYNOPSIS

#include <math.h>

double nextafter(double x, double y);

float nextafterf(float x, float y);

HP Integrity Server Only

long double nextafterl(long double x, long double y);

extended nextafterw(extended x, extended y);

quad nextafterq(quad x, quad y);

double nexttoward(double x, long double y);

float nexttowardf(float x, long double y);

long double nexttowardl(long double x, long double y);

extended nexttowardw(extended x, long double y);

quad nexttowardq(quad x, long double y);

DESCRIPTION

The nextafter() function computes the next representable double-precision value following x in the direction of y. Thus, if y is less than x, nextafter() returns the largest representable floating-point number less than x.

The nextafter() function returns y if x equals y.

The nexttoward() function is equivalent to nextafter() except that the second parameter has type long double and the function returns y converted to the type of the function if x equals y.

The result of the nexttoward() function is determined in the type of the function, without loss of range or precision in a floating second argument, whose type may be wider than the type of the function.

nextafterf() is a float versions of nextafter(); it takes float arguments and returns a float result.

nextafterl() is a long double version of nextafter(); it takes long double arguments and returns a long double result.

nextafterw() is an extended version of nextafter(); it takes extended arguments and returns an extended result.

nextafterq() is equivalent to nextafterl() on HP-UX systems.

nexttowardf() is a float versions of nexttoward(); it takes a float first argument and returns a float result.

nexttowardl() is equivalent to nextafterl().

nexttowardw() is an extended version of nexttoward(); it takes an extended first argument and returns an extended result.

nexttowardq() is equivalent to nexttowardl() 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 Integrity servers) nextafterw(), nextafterq(), nexttowardw(), or nexttowardq(), 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.

RETURN VALUE

If x equals y, nextafter() returns y, and nexttoward() returns y converted to the type of x.

If x or y is NaN, nextafter() and nexttoward() return NaN.

If x is finite and the correct function value would overflow, nextafter() and nexttoward() return ±HUGE_VAL (equal to +INFINITY), according to the sign of x, and raise the overflow exception.

If the return value is denormal and x!=y, these functions raise the underflow and inexact floating-point exceptions.

ERRORS

If x is finite and the correct function value would overflow, nextafter() sets errno to [ERANGE].

Integrity Server Only

HP-UX libm functions on Integrity servers do not set errno by default. For errno setting, compile with the +Olibmerrno option.

STANDARDS CONFORMANCE

nextafter() : SVID3, XPG4.2, ISO/IEC C99 (including Annex F, ``IEC 60559 floating-point arithmetic'')

nextafterf(), nextafterl(), nexttoward(), nexttowardf(), nexttowardl() : ISO/IEC C99 (including Annex F, ``IEC 60559 floating-point arithmetic'')

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