3
votes

When I execute this code on my iPad Air (iOS 7.1)

#include <arm_neon.h>

static inline void TestArmConversion()
{
    float x[2] = { 1.5, 2.6 };
    int32_t z[2];

    vst1_s32(z, vcvt_f32_s32(vld1_f32(x)));

    for (int k = 0; k < 2; k++)
    {
        printf("z[%d] = %d\n", k, z[k]);
    }
}

...I get the following result:

z[0] = 1316945920
z[1] = 1317031117

I would have expected to get

z[0] = 1 z[1] = 2

What am I doing wrong?

1

1 Answers

4
votes

You were close! You just mixed up the conversion. Use vcvt_s32_f32(float32x2_t) instead.