aboutsummaryrefslogtreecommitdiff
path: root/newlib/libm/math/ef_sqrt.c
diff options
context:
space:
mode:
authorRichard Sandiford <rdsandiford@googlemail.com>2001-04-04 13:33:01 +0000
committerRichard Sandiford <rdsandiford@googlemail.com>2001-04-04 13:33:01 +0000
commit16740220a22d09a1c63714d93f1efc5fbe3927f3 (patch)
tree7b24242b9b20a0ee328c94acd2c95e1a8778c944 /newlib/libm/math/ef_sqrt.c
parent51fc3813e9a9ef8079b2fbde1b12647dd3f4ac93 (diff)
downloadnewlib-16740220a22d09a1c63714d93f1efc5fbe3927f3.zip
newlib-16740220a22d09a1c63714d93f1efc5fbe3927f3.tar.gz
newlib-16740220a22d09a1c63714d93f1efc5fbe3927f3.tar.bz2
* 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.
Diffstat (limited to 'newlib/libm/math/ef_sqrt.c')
-rw-r--r--newlib/libm/math/ef_sqrt.c18
1 files changed, 8 insertions, 10 deletions
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;
}