Mercurial > hg > CbC > CbC_gcc
comparison libquadmath/math/frexpq.c @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 04ced10e8804 |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
1 /* frexpq.c -- __float128 version of s_frexp.c. | 1 /* s_frexpl.c -- long double version of s_frexp.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 * ==================================================== |
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 */ | 14 */ |
15 | 15 |
16 #if defined(LIBM_SCCS) && !defined(lint) | |
17 static char rcsid[] = "$NetBSD: $"; | |
18 #endif | |
19 | |
16 /* | 20 /* |
17 * for non-zero x | 21 * for non-zero x |
18 * x = frexpq(arg,&exp); | 22 * x = frexpq(arg,&exp); |
19 * return a __float128 fp quantity x such that 0.5 <= |x| <1.0 | 23 * return a long double fp quantity x such that 0.5 <= |x| <1.0 |
20 * and the corresponding binary exponent "exp". That is | 24 * and the corresponding binary exponent "exp". That is |
21 * arg = x*2^exp. | 25 * arg = x*2^exp. |
22 * If arg is inf, 0.0, or NaN, then frexpq(arg,&exp) returns arg | 26 * If arg is inf, 0.0, or NaN, then frexpq(arg,&exp) returns arg |
23 * with *exp=0. | 27 * with *exp=0. |
24 */ | 28 */ |
26 #include "quadmath-imp.h" | 30 #include "quadmath-imp.h" |
27 | 31 |
28 static const __float128 | 32 static const __float128 |
29 two114 = 2.0769187434139310514121985316880384E+34Q; /* 0x4071000000000000, 0 */ | 33 two114 = 2.0769187434139310514121985316880384E+34Q; /* 0x4071000000000000, 0 */ |
30 | 34 |
31 __float128 | 35 __float128 frexpq(__float128 x, int *eptr) |
32 frexpq (__float128 x, int *eptr) | |
33 { | 36 { |
34 uint64_t hx, lx, ix; | 37 uint64_t hx, lx, ix; |
35 GET_FLT128_WORDS64(hx,lx,x); | 38 GET_FLT128_WORDS64(hx,lx,x); |
36 ix = 0x7fffffffffffffffULL&hx; | 39 ix = 0x7fffffffffffffffULL&hx; |
37 *eptr = 0; | 40 *eptr = 0; |
38 if(ix>=0x7fff000000000000ULL||((ix|lx)==0)) return x + x;/* 0,inf,nan */ | 41 if(ix>=0x7fff000000000000ULL||((ix|lx)==0)) return x + x;/* 0,inf,nan */ |
39 if (ix<0x0001000000000000ULL) { /* subnormal */ | 42 if (ix<0x0001000000000000ULL) { /* subnormal */ |
40 x *= two114; | 43 x *= two114; |
41 GET_FLT128_MSW64(hx,x); | 44 GET_FLT128_MSW64(hx,x); |
42 ix = hx&0x7fffffffffffffffULL; | 45 ix = hx&0x7fffffffffffffffULL; |
43 *eptr = -114; | 46 *eptr = -114; |
44 } | 47 } |
45 *eptr += (ix>>48)-16382; | 48 *eptr += (ix>>48)-16382; |
46 hx = (hx&0x8000ffffffffffffULL) | 0x3ffe000000000000ULL; | 49 hx = (hx&0x8000ffffffffffffULL) | 0x3ffe000000000000ULL; |
47 SET_FLT128_MSW64(x,hx); | 50 SET_FLT128_MSW64(x,hx); |
48 return x; | 51 return x; |
49 } | 52 } |