How to trim float values ​​in XMM register

How to get only the whole part of a float? So, I have a float array: x [4] = {5.0, 13.0, 25.0, 41.0}; I put it in xmm0 and then I do it sqrt. I need another command to help accept only the inside of this sqrt. For example, sqrt out of 5 will be 2.236068, and I need only 2.0 in the answer
Code:

__asm 
        {
            movups xmm0, x
            sqrtps xmm0, xmm0
            //here need some command
            movups x, xmm0
        }
+4
source share
2 answers

Use roundpsis the easiest. The rounding mode table is somewhere else, but you need rounding mode 3 (to zero).

, ( 0 4.6e18 - ). cvttps2dq cvtdq2ps. SSE2, roundps SSE4.1. cvtps2dq , , , + .

+4

fooobar.com/questions/464446/..., :

, float int, , ( ).

Windows ( ) intrinsics ( ), , . MSVC Intel (float to int: . 42; float floor(float) : . 135).

Caveat

. .

+3

Source: https://habr.com/ru/post/1618558/


All Articles