Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Math 为什么要将原始数据除以16?_Math_Hex_Imp_Squirrel - Fatal编程技术网

Math 为什么要将原始数据除以16?

Math 为什么要将原始数据除以16?,math,hex,imp,squirrel,Math,Hex,Imp,Squirrel,阅读第3页,操作-测量温度。下面的代码用于获取temp。我完全理解,除了为什么他们把数字除以16 local raw = (data[1] << 8) | data[0]; local SignBit = raw & 0x8000; // test most significant bit if (SignBit) {raw = (raw ^ 0xffff) + 1;} // negative, 2's compliment local celsi

阅读第3页,操作-测量温度。下面的代码用于获取temp。我完全理解,除了为什么他们把数字除以16

local raw = (data[1] << 8) | data[0];
    local SignBit = raw & 0x8000;  // test most significant bit
    if (SignBit) {raw = (raw ^ 0xffff) + 1;} // negative, 2's compliment

    local celsius = raw / 16.0;
    if (SignBit) {celsius *= -1;}

localraw=(数据[1]原始温度数据以摄氏十六度为单位,因此必须将该值除以16才能将其转换为摄氏度。

@NathanHughes这在这个问题上真的很重要吗?请参阅您链接的数据表中的表1-温度的分辨率为0.0625摄氏度,例如07D0h=125摄氏度。另外,tagging与相关语言一起启用语法突出显示,从而使代码更具可读性。我为你们添加了它。@Nakilon我希望我知道。