简体   繁体   English

STM32将无符号短数组转换为浮点数组

[英]STM32 convert an unsigned short array to a float array

I have been doing research in google, however I cannot find a solution. 我一直在Google做研究,但是找不到解决方案。

How to convert an unsigned short array to a float array in STM32? 如何在STM32中将无符号的short数组转换为float数组? I need to perform multiplication between an unsigned short array with a float array. 我需要在无符号短数组与浮点数组之间执行乘法。 To use FPU and DSP library for STM32F4, the unsigned array is to be converted to floating point first. 为了将FPU和DSP库用于STM32F4,必须先将无符号数组转换为浮点数。

There are only libraries converting signed short arrays to float arrays. 只有库将带符号的短数组转换为浮点数组。 How to convert an unsigned short array to a float array? 如何将无符号短数组转换为浮点数组?

By just storing them as float, I'd say: 通过将它们存储为浮点数,我会说:

void uint16_to_float(float *out, const unsigned short *in, size_t num)
{
  for(; num > 0; --num)
    *out++ = *in++;
}

It's up to the compiler to figure out what instruction(s) are best suited for this, but it's a pretty standard operation. 由编译器确定哪种指令最适合此操作,但这是一个相当标准的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM