HPlogo HP-UX Reference Volume 4 of 5 > n

nextafter(3M)

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

NAME

nextafter(), nextafterf() — next representable floating-point value

SYNOPSIS

#include <math.h>

double nextafter(double x, double y);

float nextafterf(float x, float y);

DESCRIPTION

The nextafter() function computes the next representable double-precision floating-point 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 is recommended by the IEEE-754 standard for floating-point arithmetic. The ISO/ANSI C committee has approved the nextafter() function for inclusion in the C9X draft standard.

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

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

The nextafter() and nextafterf() functions return the next representable double-precision or single-precision floating-point value following x in the direction of y.

If x or y is NaN, nextafter() returns NaN.

If x is finite and the correct function value would overflow, nextafter() returns ±HUGE_VAL (according to the sign of x) and sets errno to [ERANGE].

ERRORS

If nextafter() fails, errno is set to the following value.

[ERANGE]

The correct value would overflow.

SEE ALSO

math(5), limits(5).

STANDARDS CONFORMANCE

nextafter(): SVID3, XPG4.2

© Hewlett-Packard Development Company, L.P.