解码二进制标题值
我正在尝试解码 10 位字段中包含的磁航向。我不确定上述说明如何解释。我所做的只是取出 10 位并将它们转换为十进制,如下所示
int magneticheading = Convert.ToInt32(olotoMEbinary.Substring(14, 10), 2);
但后来我检查了 259 度只需要 9 位即可用二进制表示(100000011)。我对 180 度的最高有效位和 360/1 024 的 lsb 意味着什么感到困惑。
例如,如果我收到以下 10 位 0100001010,如何根据上述说明将它们转换为度数?
I am trying to decode the magnetic heading that is contained in a 10bit field. I am not sure how the above instructions are interpreted. What i did is just took the 10 bits and convert them to decimal like this
int magneticheading = Convert.ToInt32(olotoMEbinary.Substring(14, 10), 2);
But then i checked that 259degrees only need 9bits to be expressed in binary (100000011). I am confused about what does a most significant bit of 180 degrees mean and a lsb of 360/1 024 .
For example if i receive the following 10bits 0100001010 how are they converted to degrees according to the above instructions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用浮点数学,乘以 360 再除以 1024。
Using floating-point math, multiply by 360 and divide by 1024.
问题引用的说明缺失,但 Stephen Cleary 的方法似乎适合提供的两个数据点。将其视为从 1024 等分圆到 360 等分的单位转换可能会有所帮助。
The instructions the question references are missing, but Stephen Cleary's method appears to fit the two data points provided. It may help to think of it as a unit conversion from 1024 divisions of a circle to 360.