(_IO_init): Set _vtable_offset to 0.
[glibc/history.git] / sysdeps / libm-i387 / s_nextafterl.c
blob4596c6b93c1acde0a59983278f4dc768f6956a8b
1 /* s_nextafterl.c -- long double version of s_nextafter.c.
2 * Special version for i387.
3 * Conversion to long double by Ulrich Drepper,
4 * Cygnus Support, drepper@cygnus.com.
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 hx,hy,ix,iy;
40 u_int32_t lx,ly,esx,esy;
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 /* The additional &hx/&hy is required because Intel's extended format
48 has the normally implicit 1 explicit present. Sigh! */
49 if(((ix==0x7fff)&&(((hx|lx)|-(hx|lx))&hx)>>31!=0) || /* x is nan */
50 ((iy==0x7fff)&&(((hy|ly)|-(hy|ly))&hy)>>31!=0)) /* y is nan */
51 return x+y;
52 if(x==y) return y; /* x=y, return y */
53 if((ix|hx|lx)==0) { /* x == 0 */
54 SET_LDOUBLE_WORDS(x,esx&0x8000,0,1);/* return +-minsubnormal */
55 y = x*x;
56 if(y==x) return y; else return x; /* raise underflow flag */
58 if(esx<0x8000) { /* x > 0 */
59 if(ix>iy||((ix==iy) && (hx>hy||((hx==hy)&&(lx>ly))))) {
60 /* x > y, x -= ulp */
61 if(lx==0) {
62 if (hx==0) esx -= 1;
63 hx -= 1;
65 lx -= 1;
66 } else { /* x < y, x += ulp */
67 lx += 1;
68 if(lx==0) {
69 hx += 1;
70 if (hx==0)
71 esx += 1;
74 } else { /* x < 0 */
75 if(esy>=0||(ix>iy||((ix==iy)&&(hx>hy||((hx==hy)&&(lx>ly)))))){
76 /* x < y, x -= ulp */
77 if(lx==0) {
78 if (hx==0) esx -= 1;
79 hx -= 1;
81 lx -= 1;
82 } else { /* x > y, x += ulp */
83 lx += 1;
84 if(lx==0) {
85 hx += 1;
86 if (hx==0) esx += 1;
90 esy = esx&0x7fff;
91 if(esy==0x7fff) return x+x; /* overflow */
92 if(esy==0) { /* underflow */
93 y = x*x;
94 if(y!=x) { /* raise underflow flag */
95 SET_LDOUBLE_WORDS(y,esx,hx,lx);
96 return y;
99 SET_LDOUBLE_WORDS(x,esx,hx,lx);
100 return x;
102 weak_alias (__nextafterl, nextafterl)