Intel SSE: Why does `_mm_extract_ps` return `int` instead of `float`?

后端 未结 4 613
独厮守ぢ
独厮守ぢ 2020-12-18 23:19

Why does _mm_extract_ps return an int instead of a float?

What\'s the proper way to read a single float from an X

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-18 23:49

    From the MSDN docs, I believe you can cast the result to a float.

    Note from their example, the 0xc0a40000 value is equivalent to -5.125 (a.m128_f32[1]).

    Update: I strongly recommend the answers from @doug65536 and @PeterCordes (below) in lieu of mine, which apparently generates poorly performing code on many compilers.

提交回复
热议问题