user51511
user51511

Reputation:

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 point, ideally using SSE2. Either straight C or C++ or even asm would be fine.

Upvotes: 4

Views: 3850

Answers (1)

Potatoswatter
Potatoswatter

Reputation: 137880

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;
}

Upvotes: 2

Related Questions