nexttoward - C math.h

C examples for math.h:nexttoward

Type

function

From

<cmath>
<ctgmath>
<math.h>

Description

Returns the next representable value after x in the direction of y.

If both parameters compare equal, the function returns y converted to the return type.

Prototype

long double nexttowardl (long double x, long double y);
long double nexttoward (long double x, long double y);
     double nexttoward  (double x     , long double y);
      float nexttowardf (float x      , long double y);
      float nexttoward (float x      , long double y);
     double nexttoward (T x          , long double y);  

Parameters

Parameter Description
x Base value.
y Value toward which the return value is approximated.

Return Value

The next representable value after x in the direction of y.

Demo Code


#include <stdio.h>
#include <math.h> /* nexttoward */

int main ()//  w ww.  j  ava2  s. c om
{
  printf ("first representable value greater than zero: %e\n", nexttoward(0.0,1.0L));
  
  printf ("first representable value less than zero: %e\n", nexttoward(0.0,-1.0L));
  
  printf ("%e\n", nexttoward(10.0,-1.0L));
  return 0;
}

Related Tutorials