This documentation is archived and is not being maintained.


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 value to 32-bit integers and returns an __m64 structure containing the two 32-bit integers.

__m64 _mm_cvt_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.

Intrinsic Architecture


x86 with SSE2

Header file <intrin.h>

Rounding occurs according the rounding control bits of the MXCSR register. The default rounding mode is round-to-nearest, rounding to the even number if the decimal part is 0.5. If an overflow occurs, 0x80000000 is placed in the appropriate elements of the return value. The __m128 structure represents an XMM register and the __m64 structure represents an MMX register, so the instruction generated does not involve system memory.

This routine is only available as an intrinsic.

// _mm_cvt_ps2pi.cpp
// processor: x86
#include <intrin.h>
#include <stdio.h>

#pragma intrinsic(_mm_cvt_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_cvt_ps2pi(a);


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


102 200