I am trying to build 2^n using the double representation. The trick is (well) known
// tips to calculate 2^n using the exponent of the double IEEE representation
union ieee754{
double d;
uint32_t i[2];
};
// Converts an unsigned long long to a double
inline double uint642dp(uint64_t ll) {
ieee754 tmp;
tmp.ll=ll;
return tmp.d;
}
-----------------------------------
// e^x = 2^n e^y, n = round(x/log(2)+0.5)
double x = 4.3; // start from there
double y = round(x/log(2)+0.5)
int n = (int)y; // convert in to double
uint642dp(( ((uint64_t)n) +1023)<<52); // calculate 2^n fastly
if n = 4, it will return 16.
Presently I am looking for the same this but for SIMD calculation. Considering SSE2 double, after the round function I will get a register sse2 __m128d v = (4.0, 3.0); form this register how calculate 2^v ... I am blocked mainly due to the cast __m128d to __m128i, it does not exist (it still exists a cast but it does not move bit, just change the "interpretation" of the register double/int).
I do not want return the datas form simd register to normal register to make the transformation. It exists certainly a tips with SIMD, but I do not know it.
So Help ^_^'
Best,