简体   繁体   English

将带符号的定点转换为浮点

[英]Convert signed fixed point to float

I have got number in this mode: Value mode = 16-bit fixed point (signed) 我在这种模式下有数字:值模式= 16位固定点(有符号)

And how I can convert this number to floating point? 以及如何将这个数字转换为浮点数? Any idea? 任何想法?

Can I use this function, when this number is signed? 签署此号码后可以使用此功能吗?

float toFloat(int16_t val) {
        return ((float)val)/256.0f;
    }

Ok. 好。 I wrong understood. 我错了。 So the gyroscope data return in int16 x 1000. When I used function: 因此,陀螺仪数据以int16 x 1000返回。当我使用函数时:

float toFloat(int16_t val) {
    return ((float)val)/1000.0f;
}

Now is receiving data good. 现在接收数据良好。

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

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