123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #include <openlibm_math.h>
- #include "math_private.h"
- long double
- nextafterl(long double x, long double y)
- {
- int64_t hx,hy,ix,iy;
- u_int64_t lx,ly;
- GET_LDOUBLE_WORDS64(hx,lx,x);
- GET_LDOUBLE_WORDS64(hy,ly,y);
- ix = hx&0x7fffffffffffffffLL;
- iy = hy&0x7fffffffffffffffLL;
- if(((ix>=0x7fff000000000000LL)&&((ix-0x7fff000000000000LL)|lx)!=0) ||
- ((iy>=0x7fff000000000000LL)&&((iy-0x7fff000000000000LL)|ly)!=0))
- return x+y;
- if(x==y) return y;
- if((ix|lx)==0) {
- volatile long double u;
- SET_LDOUBLE_WORDS64(x,hy&0x8000000000000000ULL,1);
- u = x;
- u = u * u;
- return x;
- }
- if(hx>=0) {
- if(hx>hy||((hx==hy)&&(lx>ly))) {
- if(lx==0) hx--;
- lx--;
- } else {
- lx++;
- if(lx==0) hx++;
- }
- } else {
- if(hy>=0||hx>hy||((hx==hy)&&(lx>ly))){
- if(lx==0) hx--;
- lx--;
- } else {
- lx++;
- if(lx==0) hx++;
- }
- }
- hy = hx&0x7fff000000000000LL;
- if(hy==0x7fff000000000000LL) return x+x;
- if(hy==0) {
- volatile long double u = x*x;
- }
- SET_LDOUBLE_WORDS64(x,hx,lx);
- return x;
- }
- __strong_alias(nexttowardl, nextafterl);
|