我正在 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/