开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜