obsolete files removed
[glibc-ports.git] / sysdeps / m68k / fpu / s_nextafterl.c
blob70ab5a478426fdcbf31917fd30dc725e300c00be
1 /* s_nextafterl.c -- long double version of s_nextafter.c.
2 * Conversion to long double by Ulrich Drepper,
3 * Cygnus Support, drepper@cygnus.com.
4 * Fixed for m68k by Andreas Schwab <schwab@suse.de>.
5 */
7 /*
8 * ====================================================
9 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
11 * Developed at SunPro, a Sun Microsystems, Inc. business.
12 * Permission to use, copy, modify, and distribute this
13 * software is freely granted, provided that this notice
14 * is preserved.
15 * ====================================================
18 #if defined(LIBM_SCCS) && !defined(lint)
19 static char rcsid[] = "$NetBSD: $";
20 #endif
22 /* IEEE functions
23 * nextafterl(x,y)
24 * return the next machine floating-point number of x in the
25 * direction toward y.
26 * Special cases:
29 #include "math.h"
30 #include "math_private.h"
32 #ifdef __STDC__
33 long double __nextafterl(long double x, long double y)
34 #else
35 long double __nextafterl(x,y)
36 long double x,y;
37 #endif
39 int32_t ix,iy,esx,esy;
40 u_int32_t hx,hy,lx,ly;
42 GET_LDOUBLE_WORDS(esx,hx,lx,x);
43 GET_LDOUBLE_WORDS(esy,hy,ly,y);
44 ix = esx&0x7fff; /* |x| */
45 iy = esy&0x7fff; /* |y| */
47 if(((ix==0x7fff)&&((hx&0x7fffffff)|lx)!=0) || /* x is nan */
48 ((iy==0x7fff)&&((hy&0x7fffffff)|ly)!=0)) /* y is nan */
49 return x+y;
50 if(x==y) return y; /* x=y, return y */
51 if((ix|hx|lx)==0) { /* x == 0 */
52 SET_LDOUBLE_WORDS(x,esy&0x8000,0,1);/* return +-minsubnormal */
53 y = x*x;
54 if(y==x) return y; else return x; /* raise underflow flag */
56 if(esx>=0) { /* x > 0 */
57 if(esx>esy||((esx==esy) && (hx>hy||((hx==hy)&&(lx>ly))))) {
58 /* x > y, x -= ulp */
59 if(lx==0) {
60 if (ix != 0 && hx == 0x80000000) hx = 0;
61 if (hx==0) esx -= 1;
62 hx -= 1;
64 lx -= 1;
65 } else { /* x < y, x += ulp */
66 lx += 1;
67 if(lx==0) {
68 hx += 1;
69 if (hx==0) {
70 hx = 0x80000000;
71 esx += 1;
75 } else { /* x < 0 */
76 if(esy>=0||esx>esy||((esx==esy) && (hx>hy||((hx==hy)&&(lx>ly))))){
77 /* x < y, x -= ulp */
78 if(lx==0) {
79 if (ix != 0 && hx == 0x80000000) hx = 0;
80 if (hx==0) esx -= 1;
81 hx -= 1;
83 lx -= 1;
84 } else { /* x > y, x += ulp */
85 lx += 1;
86 if(lx==0) {
87 hx += 1;
88 if (hx==0) {
89 hx = 0x80000000;
90 esx += 1;
95 esy = esx&0x7fff;
96 if(esy==0x7fff) return x+x; /* overflow */
97 if(esy==0 && (hx & 0x80000000) == 0) { /* underflow */
98 y = x*x;
99 if(y!=x) { /* raise underflow flag */
100 SET_LDOUBLE_WORDS(y,esx,hx,lx);
101 return y;
104 SET_LDOUBLE_WORDS(x,esx,hx,lx);
105 return x;
107 weak_alias (__nextafterl, nextafterl)
108 strong_alias (__nextafterl, __nexttowardl)
109 weak_alias (__nextafterl, nexttowardl)