Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Collapse the table of content
Expand the table of content


Microsoft Specific

Generates the Convert Packed Single-Precision Floating-Point Values to Packed Doubleword Integers (cvtps2pi) instruction, which converts the floating-point values in the first two elements in the __m128 structure valueto 32-bit integers and returns an __m64 structure containing the two 32-bit integers.

__m64 _mm_cvtt_ps2pi( 
   __m128 value 

[in] value

An __m128 structure containing four single-precision floating-point values.

An __m64 structure containing the two 32-bit integers resulting from the conversion.




x86 with SSE2

Header file <intrin.h>

This intrinsic differs from _mm_cvt_ps2pi only in that the floating-point values are truncated rather than rounded according to the setting of the MXCSR register.

Because __m128 represents an XMM register and __m64 represents an MMX register, this intrinsic generates an instruction that operates on these registers directly and does not involve system memory.

This routine is only available as an intrinsic.

// _mm_cvtt_ps2pi.cpp
// processor: x86

#include <intrin.h>
#include <stdio.h>

#pragma intrinsic(_mm_cvtt_ps2pi)

int main()
    __m128 a;
    __m64 b;

    float af[4] = { 101.5, 200.5,300.5, 400.5 };

    // Load a with the floating point values
    // _mm_loadu_ps allowed unaligned addresses
    a = _mm_loadu_ps(af);

    b = _mm_cvtt_ps2pi(a);

    // Return to floating point 

    // Print out the values in b
    printf_s("%d %d\n", b.m64_i32[0], b.m64_i32[1]);
101 200

Community Additions

© 2015 Microsoft