Mercurial > hg > CbC > CbC_gcc
comparison libquadmath/math/scalblnq.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | 561a7518be6b |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 /* s_scalblnl.c -- long double version of s_scalbn.c. | 1 /* scalblnq.c -- __float128 version of s_scalbn.c. |
2 * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz. | 2 * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz. |
3 */ | 3 */ |
4 | 4 |
5 /* | 5 /* |
6 * ==================================================== | 6 * ==================================================== |
7 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. | 7 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
8 * | 8 * |
9 * Developed at SunPro, a Sun Microsystems, Inc. business. | 9 * Developed at SunPro, a Sun Microsystems, Inc. business. |
10 * Permission to use, copy, modify, and distribute this | 10 * Permission to use, copy, modify, and distribute this |
11 * software is freely granted, provided that this notice | 11 * software is freely granted, provided that this notice |
12 * is preserved. | 12 * is preserved. |
13 * ==================================================== | 13 * ==================================================== |
14 */ | |
15 | |
16 /* | |
17 * scalblnq (_float128 x, long int n) | |
18 * scalblnq(x,n) returns x* 2**n computed by exponent | |
19 * manipulation rather than by actually performing an | |
20 * exponentiation or a multiplication. | |
14 */ | 21 */ |
15 | 22 |
16 #include "quadmath-imp.h" | 23 #include "quadmath-imp.h" |
17 | 24 |
18 static const __float128 | 25 static const __float128 |
32 x *= two114; | 39 x *= two114; |
33 GET_FLT128_MSW64(hx,x); | 40 GET_FLT128_MSW64(hx,x); |
34 k = ((hx>>48)&0x7fff) - 114; | 41 k = ((hx>>48)&0x7fff) - 114; |
35 } | 42 } |
36 if (k==0x7fff) return x+x; /* NaN or Inf */ | 43 if (k==0x7fff) return x+x; /* NaN or Inf */ |
44 if (n< -50000) return tiny*copysignq(tiny,x); /*underflow*/ | |
45 if (n> 50000 || k+n > 0x7ffe) | |
46 return huge*copysignq(huge,x); /* overflow */ | |
47 /* Now k and n are bounded we know that k = k+n does not | |
48 overflow. */ | |
37 k = k+n; | 49 k = k+n; |
38 if (n> 50000 || k > 0x7ffe) | |
39 return huge*copysignq(huge,x); /* overflow */ | |
40 if (n< -50000) return tiny*copysignq(tiny,x); /*underflow*/ | |
41 if (k > 0) /* normal result */ | 50 if (k > 0) /* normal result */ |
42 {SET_FLT128_MSW64(x,(hx&0x8000ffffffffffffULL)|(k<<48)); return x;} | 51 {SET_FLT128_MSW64(x,(hx&0x8000ffffffffffffULL)|(k<<48)); return x;} |
43 if (k <= -114) | 52 if (k <= -114) |
44 return tiny*copysignq(tiny,x); /*underflow*/ | 53 return tiny*copysignq(tiny,x); /*underflow*/ |
45 k += 114; /* subnormal result */ | 54 k += 114; /* subnormal result */ |