This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

32-bit Floating to 32-bit Integer conversion on DSP C674x

Hi,

Can anybody please tell me how to do a 32-bit Floating to 32-bit Integer conversion using an intrinsic or any other optimized way? But the requirement is the o/p should match the o/p of - floor(0.5+float_number)

I tried with "_spint" but doesn't match for some values. PFA for the prints of floor(0.5+float_number) and _spint(float_number)

Thanks a lot in advance.

PS: Please see that this conversion happens in a loop so, shouldn't break software pipelining.

Regards,

Mahantesh

  • Try _fixfi(float) which is part of the COFF rts library of the compiler. The elf version of the function is __c6xabi_fixfi (float).

    Look for arithematic functions in Run time support libraries for the unsigned version of the function as well.

    Regards,

    Rahul

  • Thanks a lot for your suggestion, Rahul.. As of now I have found a work around for this. I'll soon try out your suggestions and let you know.

    Regards,

    Mahantesh

  • Dear Rahul,

    I did couple of experiments and came to know that _spint output cannot match floor(0.5+float_number) because of below points - 

    1. For floats with even significant numbers - 4.5, 6.5, 2.5,.. dsp rounds down to 4,6,2...

    2. For floats with odd significant numbers -  1.5, 3.5, 5.5,... dsp rounds up to 2,4,6,...

    3. Also, dsp takes care of negative floating points, where as just doing - floor(0.5+float_number) doesn't handle negative numbers.

    Hence the mismatch is seen between "_spint" output and "floor(0.5+float_number)" output

    Regards,

    Mahantesh