Microsoft Specific

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

__m128 _mm_castpd_ps( 
   __m128d a


  • [in] a
    A 128-bit parameter that contains two 64-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 single precision floating point values. This intrinsic changes one data type to another without performing any conversion.

This intrinsic does not map to any specific machine instruction.


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

int main () {
    __m128d a;

    a.m128d_f64[1] = 0.00125;
    a.m128d_f64[0] = 2;

    __m128 res = _mm_castpd_ps( a );

    printf_s("Original a: %8f %8f\n",
                a.m128d_f64[1], a.m128d_f64[0]);

    printf_s("Result res: %8f %8f %8f %8f\n",
                res.m128_f32[3], res.m128_f32[2], 
                res.m128_f32[1], res.m128_f32[0]);

    __m128d newA = _mm_castps_pd( res );

    printf_s("New a:      %8f %8f\n",
                newA.m128d_f64[1], newA.m128d_f64[0]);

    return 0;
Original a: 0.001250 2.000000
Result res: 0.830000 89128.960938 2.000000 0.000000
New a:      0.001250 2.000000

See Also


Compiler Intrinsics