e_pow.c (176276) | e_pow.c (226595) |
---|---|
1/* @(#)e_pow.c 1.5 04/04/22 SMI */ 2/* 3 * ==================================================== 4 * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. 5 * 6 * Permission to use, copy, modify, and distribute this 7 * software is freely granted, provided that this notice 8 * is preserved. 9 * ==================================================== 10 */ 11 12#include <sys/cdefs.h> | 1/* @(#)e_pow.c 1.5 04/04/22 SMI */ 2/* 3 * ==================================================== 4 * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. 5 * 6 * Permission to use, copy, modify, and distribute this 7 * software is freely granted, provided that this notice 8 * is preserved. 9 * ==================================================== 10 */ 11 12#include <sys/cdefs.h> |
13__FBSDID("$FreeBSD: head/lib/msun/src/e_pow.c 176266 2008-02-14 09:42:24Z bde $"); | 13__FBSDID("$FreeBSD: head/lib/msun/src/e_pow.c 226595 2011-10-21 06:26:07Z das $"); |
14 15/* __ieee754_pow(x,y) return x**y 16 * 17 * n 18 * Method: Let x = 2 * (1+f) 19 * 1. Compute and return log2(x) in two pieces: 20 * log2(x) = w1 + w2, 21 * where w1 has 53-24 = 29 bit trailing zeros. --- 82 unchanged lines hidden (view full) --- 104 105 EXTRACT_WORDS(hx,lx,x); 106 EXTRACT_WORDS(hy,ly,y); 107 ix = hx&0x7fffffff; iy = hy&0x7fffffff; 108 109 /* y==zero: x**0 = 1 */ 110 if((iy|ly)==0) return one; 111 | 14 15/* __ieee754_pow(x,y) return x**y 16 * 17 * n 18 * Method: Let x = 2 * (1+f) 19 * 1. Compute and return log2(x) in two pieces: 20 * log2(x) = w1 + w2, 21 * where w1 has 53-24 = 29 bit trailing zeros. --- 82 unchanged lines hidden (view full) --- 104 105 EXTRACT_WORDS(hx,lx,x); 106 EXTRACT_WORDS(hy,ly,y); 107 ix = hx&0x7fffffff; iy = hy&0x7fffffff; 108 109 /* y==zero: x**0 = 1 */ 110 if((iy|ly)==0) return one; 111 |
112 /* x==1: 1**y = 1, even if y is NaN */ 113 if (hx==0x3ff00000 && lx == 0) return one; 114 |
|
112 /* y!=zero: result is NaN if either arg is NaN */ 113 if(ix > 0x7ff00000 || ((ix==0x7ff00000)&&(lx!=0)) || 114 iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0))) 115 return (x+0.0)+(y+0.0); 116 117 /* determine if y is an odd int when x < 0 118 * yisint = 0 ... y is not an integer 119 * yisint = 1 ... y is an odd int --- 13 unchanged lines hidden (view full) --- 133 } 134 } 135 } 136 137 /* special value of y */ 138 if(ly==0) { 139 if (iy==0x7ff00000) { /* y is +-inf */ 140 if(((ix-0x3ff00000)|lx)==0) | 115 /* y!=zero: result is NaN if either arg is NaN */ 116 if(ix > 0x7ff00000 || ((ix==0x7ff00000)&&(lx!=0)) || 117 iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0))) 118 return (x+0.0)+(y+0.0); 119 120 /* determine if y is an odd int when x < 0 121 * yisint = 0 ... y is not an integer 122 * yisint = 1 ... y is an odd int --- 13 unchanged lines hidden (view full) --- 136 } 137 } 138 } 139 140 /* special value of y */ 141 if(ly==0) { 142 if (iy==0x7ff00000) { /* y is +-inf */ 143 if(((ix-0x3ff00000)|lx)==0) |
141 return y - y; /* inf**+-1 is NaN */ | 144 return one; /* (-1)**+-inf is NaN */ |
142 else if (ix >= 0x3ff00000)/* (|x|>1)**+-inf = inf,0 */ 143 return (hy>=0)? y: zero; 144 else /* (|x|<1)**-,+inf = inf,0 */ 145 return (hy<0)?-y: zero; 146 } 147 if(iy==0x3ff00000) { /* y is +-1 */ 148 if(hy<0) return one/x; else return x; 149 } --- 154 unchanged lines hidden --- | 145 else if (ix >= 0x3ff00000)/* (|x|>1)**+-inf = inf,0 */ 146 return (hy>=0)? y: zero; 147 else /* (|x|<1)**-,+inf = inf,0 */ 148 return (hy<0)?-y: zero; 149 } 150 if(iy==0x3ff00000) { /* y is +-1 */ 151 if(hy<0) return one/x; else return x; 152 } --- 154 unchanged lines hidden --- |