swift - 如何将二进制指数为-10的数字转换为 float ?

标签 swift bluetooth binary core-bluetooth exponent

我正在 iOS 上使用低功耗蓝牙设备,Swift 正在接收一些数据。所述数据在https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.csc_measurement.xml中指定。作为 uint16。它使用二进制指数表示,但我找不到如何将其转换为 float 以进一步使用它。

Last Wheel Event Time Information: Unit has a resolution of 1/1024s.

Unit: org.bluetooth.unit.time.second

Exponent: Binary, -10

我想只计算 10 位,并将第一段用作小数点之前的部分,将第二段用作小数点后的部分。但是结果好像不对。

非常感谢任何提示或解决方案。

非常感谢。

最佳答案

-10 的二进制指数与将 uint16 值转换为 Double 并除以 1024.0(或乘以 2 的 1.0 到第 10 次)相同。

关于swift - 如何将二进制指数为-10的数字转换为 float ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35532131/

相关文章:

c# - 如何在 C# 中读写二进制文件?

swift - NSPopover 中的 NSTableview 看起来与独立的不同

ios - 后退按钮在屏幕上显示为不同的颜色?

actionscript-3 - 如何 : force output sound of application to go through Bluetooth headset

c++ - 微:Bit read bluetooth message

c++ - 为什么fstream打印出文件的最后一条记录

javascript - 检查两个具有浮点值的对象是否相等?

ios - 如何判断对象是不是 UIImage?

ios - swift 错误 : value of optional type 'Double?' not unwrapped

android - 自动查找已配对的蓝牙设备,当它们在范围内时