mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-22 21:10:07 +00:00
f7eac6eb50
* Makeconfig ($(common-objpfx)config.make): Depend on config.h.in. Mon Mar 4 17:35:09 1996 Roland McGrath <roland@charlie-brown.gnu.ai.mit.edu> * hurd/catch-signal.c (hurd_safe_memmove): New function. (hurd_safe_copyin, hurd_safe_copyout): New functions. * hurd/hurd/sigpreempt.h: Declare them. Sun Mar 3 08:43:44 1996 Roland McGrath <roland@charlie-brown.gnu.ai.mit.edu> Replace math code with fdlibm from Sun as modified for netbsd by JT Conklin and Ian Taylor, including x86 FPU support. * sysdeps/libm-ieee754, sysdeps/libm-i387: New directories. * math/math_private.h: New file. * sysdeps/i386/fpu/Implies: New file. * sysdeps/ieee754/Implies: New file. * math/machine/asm.h, math/machine/endian.h: New files. * math/Makefile, math/math.h: Rewritten. * mathcalls.h, math/mathcalls.h: New file, broken out of math.h. * math/finite.c: File removed. * sysdeps/generic/Makefile [$(subdir)=math]: Frobnication removed. * math/test-math.c: Include errno.h and string.h. * sysdeps/unix/bsd/dirstream.h: File removed. * sysdeps/unix/bsd/readdir.c: File removed.
81 lines
2.0 KiB
C
81 lines
2.0 KiB
C
/* @(#)s_nextafter.c 5.1 93/09/24 */
|
|
/*
|
|
* ====================================================
|
|
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
|
*
|
|
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
|
* Permission to use, copy, modify, and distribute this
|
|
* software is freely granted, provided that this notice
|
|
* is preserved.
|
|
* ====================================================
|
|
*/
|
|
|
|
#if defined(LIBM_SCCS) && !defined(lint)
|
|
static char rcsid[] = "$NetBSD: s_nextafter.c,v 1.8 1995/05/10 20:47:58 jtc Exp $";
|
|
#endif
|
|
|
|
/* IEEE functions
|
|
* nextafter(x,y)
|
|
* return the next machine floating-point number of x in the
|
|
* direction toward y.
|
|
* Special cases:
|
|
*/
|
|
|
|
#include "math.h"
|
|
#include "math_private.h"
|
|
|
|
#ifdef __STDC__
|
|
double __nextafter(double x, double y)
|
|
#else
|
|
double __nextafter(x,y)
|
|
double x,y;
|
|
#endif
|
|
{
|
|
int32_t hx,hy,ix,iy;
|
|
u_int32_t lx,ly;
|
|
|
|
EXTRACT_WORDS(hx,lx,x);
|
|
EXTRACT_WORDS(hy,ly,y);
|
|
ix = hx&0x7fffffff; /* |x| */
|
|
iy = hy&0x7fffffff; /* |y| */
|
|
|
|
if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) || /* x is nan */
|
|
((iy>=0x7ff00000)&&((iy-0x7ff00000)|ly)!=0)) /* y is nan */
|
|
return x+y;
|
|
if(x==y) return x; /* x=y, return x */
|
|
if((ix|lx)==0) { /* x == 0 */
|
|
INSERT_WORDS(x,hy&0x80000000,1); /* return +-minsubnormal */
|
|
y = x*x;
|
|
if(y==x) return y; else return x; /* raise underflow flag */
|
|
}
|
|
if(hx>=0) { /* x > 0 */
|
|
if(hx>hy||((hx==hy)&&(lx>ly))) { /* x > y, x -= ulp */
|
|
if(lx==0) hx -= 1;
|
|
lx -= 1;
|
|
} else { /* x < y, x += ulp */
|
|
lx += 1;
|
|
if(lx==0) hx += 1;
|
|
}
|
|
} else { /* x < 0 */
|
|
if(hy>=0||hx>hy||((hx==hy)&&(lx>ly))){/* x < y, x -= ulp */
|
|
if(lx==0) hx -= 1;
|
|
lx -= 1;
|
|
} else { /* x > y, x += ulp */
|
|
lx += 1;
|
|
if(lx==0) hx += 1;
|
|
}
|
|
}
|
|
hy = hx&0x7ff00000;
|
|
if(hy>=0x7ff00000) return x+x; /* overflow */
|
|
if(hy<0x00100000) { /* underflow */
|
|
y = x*x;
|
|
if(y!=x) { /* raise underflow flag */
|
|
INSERT_WORDS(y,hx,lx);
|
|
return y;
|
|
}
|
|
}
|
|
INSERT_WORDS(x,hx,lx);
|
|
return x;
|
|
}
|
|
weak_alias (__nextafter, nextafter)
|