this repo has no description
1/*
2 * xmm_nextafter.c
3 * xmmLibm
4 *
5 * Created by Ian Ollmann on 8/19/05.
6 * Copyright 2005 Apple Computer. All rights reserved.
7 *
8 */
9
10#include "fenv.h"
11#include "xmmLibm_prefix.h"
12#include "math.h"
13
14
15float nexttowardf( float x, long double y )
16{
17
18 //must be a x or y is NaN
19 if( EXPECT_FALSE( x != x ) )
20 return x + x;
21
22 if( EXPECT_TRUE( (long double) x < y ) )
23 return nextafterf( x, __builtin_inff() );
24
25 if( EXPECT_TRUE( (long double) x > y ) )
26 return nextafterf( x, -__builtin_inff() );
27
28 if( EXPECT_TRUE( (long double) x == y ) )
29 return y;
30
31 return y + y;
32}
33
34double nexttoward( double x, long double y )
35{
36
37 //must be a x or y is NaN
38 if( EXPECT_FALSE( x != x ) )
39 return x + x;
40
41 if( EXPECT_TRUE( (long double) x < y ) )
42 return nextafter( x, __builtin_inff() );
43
44 if( EXPECT_TRUE( (long double) x > y ) )
45 return nextafter( x, -__builtin_inff() );
46
47 if( EXPECT_TRUE( (long double) x == y ) )
48 return y;
49
50 return y + y;
51}
52
53