Name

nexttoward

Synopsis

Obtains the next representable value in the direction of a given long double value

#include <math.h>
doublenexttoward( double x, long double y );
float nexttowardf( float x, long double y );
long double nexttowardl( long double x, long double y );

The nexttoward() functions are similar to nextafter(), except that the second parameter in all three variants has the type long double.

Example

float x =nexttowardf( 0.0F, -1E-100L );
printf("The greatest negative floating-point number \n"
       "(i.e., the closest to zero) with type float: %E\n", x);

This code produces output like the following:

The greatest negative floating-point number
(i.e., the closest to zero) with type float: -1.401298E-45

Get C in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.