1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- #include "cdefs-compat.h"
- #include <float.h>
- #include <openlibm_math.h>
- #include "math_private.h"
- OLM_DLLEXPORT double
- nextafter(double x, double y)
- {
- volatile double t;
- int32_t hx,hy,ix,iy;
- u_int32_t lx,ly;
- EXTRACT_WORDS(hx,lx,x);
- EXTRACT_WORDS(hy,ly,y);
- ix = hx&0x7fffffff;
- iy = hy&0x7fffffff;
- if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) ||
- ((iy>=0x7ff00000)&&((iy-0x7ff00000)|ly)!=0))
- return x+y;
- if(x==y) return y;
- if((ix|lx)==0) {
- INSERT_WORDS(x,hy&0x80000000,1);
- t = x*x;
- if(t==x) return t; else return x;
- }
- if(hx>=0) {
- if(hx>hy||((hx==hy)&&(lx>ly))) {
- if(lx==0) hx -= 1;
- lx -= 1;
- } else {
- lx += 1;
- if(lx==0) hx += 1;
- }
- } else {
- if(hy>=0||hx>hy||((hx==hy)&&(lx>ly))){
- if(lx==0) hx -= 1;
- lx -= 1;
- } else {
- lx += 1;
- if(lx==0) hx += 1;
- }
- }
- hy = hx&0x7ff00000;
- if(hy>=0x7ff00000) return x+x;
- if(hy<0x00100000) {
- t = x*x;
- if(t!=x) {
- INSERT_WORDS(y,hx,lx);
- return y;
- }
- }
- INSERT_WORDS(x,hx,lx);
- return x;
- }
- #if (LDBL_MANT_DIG == 53)
- __weak_reference(nextafter, nexttoward);
- __weak_reference(nextafter, nexttowardl);
- __weak_reference(nextafter, nextafterl);
- #endif
|