Microsoft Specific

Applies a type cast to reinterpret four 32-bit floating point values passed in as a 128-bit parameter as packed 32-bit integers.

__m128i _mm_castps_si128( 
   __m128 a


  • [in] a
    A 128-bit parameter that contains four 32-bit floating point values.

Return value

r := a





x86, x64

Header file <emmintrin.h>


The 128-bit return value r is a copy of the 128-bit parameter a, but cast as four 32-bit integers. This intrinsic changes one data type to another without performing any conversion.

This intrinsic does not map to any specific machine instruction.


// _mm_castps_si128.cpp
#include <stdio.h>
#include <emmintrin.h>

int main () {
    __m128 a;

    a.m128_f32[3] = 0.5;
    a.m128_f32[2] = 89129;
    a.m128_f32[1] = 2.000000;
    a.m128_f32[0] = 0.000000;

    __m128i res = _mm_castps_si128( a );

    printf_s("Original a: %12f %12f %12f %12f\n",
                a.m128_f32[3], a.m128_f32[2], 
                a.m128_f32[1], a.m128_f32[0]);

    printf_s("Result res: %12i %12i %12i %12i\n",
                res.m128i_i32[3], res.m128i_i32[2],
                res.m128i_i32[1], res.m128i_i32[0]);

    __m128 newA = _mm_castsi128_ps( res );

    printf_s("New a:      %12f %12f %12f %12f\n",
                newA.m128_f32[3], newA.m128_f32[2], 
                newA.m128_f32[1], newA.m128_f32[0]);

    return 0;
Original a:     0.500000 89129.000000     2.000000     0.000000
Result res:   1056964608   1202590848   1073741824            0
New a:          0.500000 89129.000000     2.000000     0.000000

See Also


Compiler Intrinsics