From 16740220a22d09a1c63714d93f1efc5fbe3927f3 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Wed, 4 Apr 2001 13:33:01 +0000 Subject: * libc/include/machine/ieeefp.h: Comment about new configuration macros _FLT_LARGEST_EXPONENT_IS_NORMAL and _FLT_NO_DENORMALS. * libm/common/fdlib.h: Define new macros for testing floats. * libm/common/sf_*: Use them. * libm/math/ef_*: Likewise. * libm/math/sf_*: Likewise. --- newlib/libm/math/ef_sqrt.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'newlib/libm/math/ef_sqrt.c') diff --git a/newlib/libm/math/ef_sqrt.c b/newlib/libm/math/ef_sqrt.c index aabbc51..17dab93 100644 --- a/newlib/libm/math/ef_sqrt.c +++ b/newlib/libm/math/ef_sqrt.c @@ -30,25 +30,23 @@ static float one = 1.0, tiny=1.0e-30; { float z; __int32_t sign = (__int32_t)0x80000000; - __uint32_t r; + __uint32_t r,hx; __int32_t ix,s,q,m,t,i; GET_FLOAT_WORD(ix,x); + hx = ix&0x7fffffff; /* take care of Inf and NaN */ - if((ix&0x7f800000L)==0x7f800000L) { + if(!FLT_UWORD_IS_FINITE(hx)) return x*x+x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf sqrt(-inf)=sNaN */ - } - /* take care of zero */ - if(ix<=0) { - if((ix&(~sign))==0) return x;/* sqrt(+-0) = +-0 */ - else if(ix<0) - return (x-x)/(x-x); /* sqrt(-ve) = sNaN */ - } + /* take care of zero and -ves */ + if(FLT_UWORD_IS_ZERO(hx)) return x;/* sqrt(+-0) = +-0 */ + if(ix<0) return (x-x)/(x-x); /* sqrt(-ve) = sNaN */ + /* normalize x */ m = (ix>>23); - if(m==0) { /* subnormal x */ + if(FLT_UWORD_IS_SUBNORMAL(hx)) { /* subnormal x */ for(i=0;(ix&0x00800000L)==0;i++) ix<<=1; m -= i-1; } -- cgit v1.1