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 Doubleword Integer to Scalar Single-Precision Floating-Point Value (cvtsi2ss) instruction, which converts the 32-bit integer b to a single-precision floating-point value using the rounding behavior specified by the rounding control bits in MXCSR.

__m128 _mm_cvt_si2ss( 
   __m128 a, 
   int b 

[in] a

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

[in] b

A 32-bit integer to be converted.

An __m128 structure with the result of the conversion in the first element and the remaining elements copied from a.




x86 with SSE2, x64

Header file <intrin.h>

The default rounding mode is round to nearest, rounding to the even number if the decimal part is 0.5. The result is placed in the first doubleword of the result; the other three doublewords of the result are copied from a. The __m128 structure represents an XMM register, so this intrinsic allows a value from system memory to be moved into the register.

This routine is only available as an intrinsic.

// _mm_cvt_si2ss.cpp
// processor: x86, x64
#include <intrin.h>
#include <stdio.h>

#pragma intrinsic(_mm_cvt_si2ss)
// _mm_empty is only available and only required on x86
#ifdef _M_IX86
#pragma intrinsic( _mm_empty)

int main()
    __m128 a;
    int b = 100;

    float af[4] = { 101.25, 200.75,300.5, 400.5 };

    // Load a with the floating point values.
    // The values will be copied to the XMM registers.
    a = _mm_loadu_ps(af);

    // Copy b into the first element of a
    a = _mm_cvt_si2ss(a, b);

    // Switch back to floating point (x86 only).
#ifdef _M_IX86

    // Print out the values in a
    printf_s("%lf %lf %lf %lf\n", a.m128_f32[0], a.m128_f32[1],
             a.m128_f32[2], a.m128_f32[3] );
100.000000 200.750000 300.500000 400.500000

Community Additions

© 2015 Microsoft