开发者

Fastest way to convert 16.16 fixed point to 32 bit float in c/c++ on x86?

开发者 https://www.devze.com 2022-12-20 04:23 出处:网络
Most people seem to want to go the other way. I\'m wondering if there is a fast way to convert fixed point to floating poin开发者_运维技巧t, ideally using SSE2. Either straight C or C++ or even asm wo

Most people seem to want to go the other way. I'm wondering if there is a fast way to convert fixed point to floating poin开发者_运维技巧t, ideally using SSE2. Either straight C or C++ or even asm would be fine.


It's easy as long as you have a double-precision FPU: there are 53 bits of significant figures. SSE2 has double-precision.

float conv_fx( int32_t fx ) {
    double fp = fx;
    fp = fp / double(1<<16); // multiplication by a constant
    return fp;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号