• <bdo id='vvy8w'></bdo><ul id='vvy8w'></ul>
    <tfoot id='vvy8w'></tfoot>

  • <legend id='vvy8w'><style id='vvy8w'><dir id='vvy8w'><q id='vvy8w'></q></dir></style></legend>
    <i id='vvy8w'><tr id='vvy8w'><dt id='vvy8w'><q id='vvy8w'><span id='vvy8w'><b id='vvy8w'><form id='vvy8w'><ins id='vvy8w'></ins><ul id='vvy8w'></ul><sub id='vvy8w'></sub></form><legend id='vvy8w'></legend><bdo id='vvy8w'><pre id='vvy8w'><center id='vvy8w'></center></pre></bdo></b><th id='vvy8w'></th></span></q></dt></tr></i><div id='vvy8w'><tfoot id='vvy8w'></tfoot><dl id='vvy8w'><fieldset id='vvy8w'></fieldset></dl></div>

      <small id='vvy8w'></small><noframes id='vvy8w'>

        经度读数以 1x10^-7 度 lsb 为单位测量,带符号 2 的补码

        时间:2023-10-20
          <tbody id='MhqRy'></tbody>

          • <tfoot id='MhqRy'></tfoot>
            <legend id='MhqRy'><style id='MhqRy'><dir id='MhqRy'><q id='MhqRy'></q></dir></style></legend>
            • <bdo id='MhqRy'></bdo><ul id='MhqRy'></ul>

                <i id='MhqRy'><tr id='MhqRy'><dt id='MhqRy'><q id='MhqRy'><span id='MhqRy'><b id='MhqRy'><form id='MhqRy'><ins id='MhqRy'></ins><ul id='MhqRy'></ul><sub id='MhqRy'></sub></form><legend id='MhqRy'></legend><bdo id='MhqRy'><pre id='MhqRy'><center id='MhqRy'></center></pre></bdo></b><th id='MhqRy'></th></span></q></dt></tr></i><div id='MhqRy'><tfoot id='MhqRy'></tfoot><dl id='MhqRy'><fieldset id='MhqRy'></fieldset></dl></div>

                  <small id='MhqRy'></small><noframes id='MhqRy'>

                1. 本文介绍了经度读数以 1x10^-7 度 lsb 为单位测量,带符号 2 的补码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在通过 udp 数据包从 gps 单元接收数据.Lat/Lng 值是十六进制的.

                  I am receiving data from a gps unit via a udp packet. Lat/Lng values are in hex.

                  示例数据
                  13BF71A8 = 纬度 (33.1313576)
                  BA18A506 = 经度 (-117.2790010)

                  Example Data
                  13BF71A8 = Latitude (33.1313576)
                  BA18A506 = Longitude (-117.2790010)

                  文档解释说,经度/纬度读数以度为单位测量,1x10^-7 度 lsb,带符号 2 的补码.

                  The documentation explains that longitude/latitude readings are measured in degrees with a 1x10^-7 degree lsb, signed 2’s complement.

                  对于纬度,我可以使用以下公式进行转换:
                  13BF71A8 = 331313576 * 0.0000001 = 33.1313576

                  For the Latitude I can convert using this formula:
                  13BF71A8 = 331313576 * 0.0000001 = 33.1313576

                  此代码适用于 Lat 但不适用于 Lng:

                  This code works for Lat but not for Lng:

                  function convertLat(h){
                  var latdec = parseInt(h,16);
                      var lat = latdec * 0.0000001;
                      return lat;
                  }
                  
                  console.log("LAT: " + convertLat("13BF71A8"));
                  

                  我在转换经度值时遇到问题.有谁知道如何转换经度?

                  I am having trouble converting the Longitude value. Does anyone know how to convert the Longitude?

                  推荐答案

                  因为你使用的是有符号数,所以你需要指定一个十六进制代码应该翻转到底部的点.这将发生在 7FFFFFFF 及以上.现在更新您的代码以检查输入是否大于此数字,如果是,则从输入中减去它.

                  Because you are using signed numbers, you need to specify a point at which the hexadecimal code should flip to the bottom. This will be happening at 7FFFFFFF and up. Now update your code to check if the input is greater than this number, and if so, subtract it from the input.

                  function convert(h) {
                      dec = parseInt(h, 16);
                      return (dec < parseInt('7FFFFFFF', 16)) ?
                          dec * 0.0000001 :
                          0 - ((parseInt('FFFFFFFF', 16) - dec) * 0.0000001);
                  }
                  

                  您的示例有效的唯一原因是预期输出为正数.

                  The only reason your example worked is because the output was expected to be positive.

                  正如评论中提到的 AlexWien:由于每次解析 7FFFFFFFFFFFFFFF 都会给出相同的整数,因此您可以将它们存储为常量.它们的值分别是 21474836474294967295.

                  As AlexWien mentioned in the comments: Since parsing 7FFFFFFF and FFFFFFFF are giving the same integers every time, you could store them as constants. Their values are 2147483647 and 4294967295 respectively.

                  这篇关于经度读数以 1x10^-7 度 lsb 为单位测量,带符号 2 的补码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:只有 HTML/JS 和谷歌地图上的实时 GPS 追踪器可以在手机上运行?是否可以? 下一篇:在纠正用 Javascript (node.js) 编写的 CRC-ITU 检查方法中的问题时需要帮助

                  相关文章

                2. <small id='MOOEk'></small><noframes id='MOOEk'>

                    <legend id='MOOEk'><style id='MOOEk'><dir id='MOOEk'><q id='MOOEk'></q></dir></style></legend>
                      <bdo id='MOOEk'></bdo><ul id='MOOEk'></ul>

                      <i id='MOOEk'><tr id='MOOEk'><dt id='MOOEk'><q id='MOOEk'><span id='MOOEk'><b id='MOOEk'><form id='MOOEk'><ins id='MOOEk'></ins><ul id='MOOEk'></ul><sub id='MOOEk'></sub></form><legend id='MOOEk'></legend><bdo id='MOOEk'><pre id='MOOEk'><center id='MOOEk'></center></pre></bdo></b><th id='MOOEk'></th></span></q></dt></tr></i><div id='MOOEk'><tfoot id='MOOEk'></tfoot><dl id='MOOEk'><fieldset id='MOOEk'></fieldset></dl></div>
                    1. <tfoot id='MOOEk'></tfoot>