Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1906 serge 1
/*
2
   nexttowardf.c
3
   Contributed by Danny Smith 
4
   No copyright claimed, absolutely no warranties.
5
 
6
   2005-05-10
7
*/
8
 
9
#include 
10
 
11
float
12
nexttowardf (float x, long double y)
13
{
14
  union
15
  {
16
    float f;
17
    unsigned int i;
18
  } u;
19
 
20
  long double xx = x;
21
 
22
  if (isnan (y) || isnan (x))
23
    return x + y;
24
  if (xx == y )
25
     /* nextafter (0.0, -O.0) should return -0.0.  */
26
     return y;
27
  u.f = x;
28
  if (x == 0.0F)
29
    {
30
      u.i = 1;
31
      return y > 0.0L ? u.f : -u.f;
32
    }
33
  if (((x > 0.0F) ^ (y > xx)) == 0)
34
    u.i++;
35
  else
36
    u.i--;
37
  return u.f;
38
}