共用方式為


_mm_ceil_ps

Microsoft Specific

Emits the Streaming SIMD Extensions 4 (SSE4) instruction roundps. This instruction rounds up packed single precision floating point values.

__m128 _mm_ceil_ps( 
   __m128 a
);

Parameters

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

Return value

r0 := CEIL(a0)
r1 := CEIL(a1)
r2 := CEIL(a2)
r3 := CEIL(a3)

Requirements

Intrinsic

Architecture

_mm_ceil_ps

x86, x64

Header file <smmintrin.h>

Remarks

The return value r and parameter a each consist of 128 bits. r0-r3 and a0-a3 are the sequentially ordered 32-bit components of these parameters, where r0 and a0 denote the least significant 32 bits.

This function is implemented as a macro that invokes intrinsic _mm_round_ps with appropriate rounding control.

Before using this intrinsic, software must ensure that the processor supports the instruction.

Example

#include <stdio.h>
#include <smmintrin.h>

int main () {
    __m128 a;

    a.m128_f32[3] = 10.25;
    a.m128_f32[2] = -6.5;
    a.m128_f32[1] = 0;
    a.m128_f32[0] = 0.125;

    __m128 res = _mm_ceil_ps( a );


    printf_s("Original a: %8f %8f %8f %8f\n",
                a.m128_f32[3], a.m128_f32[2], a.m128_f32[1], a.m128_f32[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]);

    return 0;
}

Original a: 10.250000 -6.500000 0.000000 0.125000
Result res: 11.000000 -6.000000 0.000000 1.000000

See Also

Concepts

Compiler Intrinsics