英文:
Converting decimal number to 16 bit temperature binary
问题
我有一个关于转换的问题。
在关于DS18B20温度传感器的文档中,我需要将18.25摄氏度转换为二进制。
有人能解释一下如何做吗。
我尝试在互联网上寻找答案,但我找不到类似的东西。
英文:
I have a question about conversion.
In a document about DS18B20 temperature sensor i need to convert 18.25C to binary.
Can someone explain how to do it.
I tried looking for answers on the internet but i can't find anything similar.
答案1
得分: 0
看起来二进制值是以0.0635度为增量的十进制温度(0.5 = 0.0625*8 = 0008h
,10.125 = 0.0625*162 = 00A2h
)
所以18.25
的转换为
18.25/0.0625 = 292 = 0124h = 0000 0001 0010 0010
或者,由于1/0.0625 = 16
,你也可以通过乘以16来进行转换:
18.25 * 16 = 292 = 0124h = 0000 0001 0010 0010
英文:
It looks like the binary value is the decimal temperature in increments of 0.0635 degrees (0.5 = 0.0625*8 = 0008h
, 10.125 = 0.0625*162 = 00A2h
)
so the conversion for 18.25
would be
18.25/0.0625 = 292 = 0124h = 0000 0001 0010 0010
Or, since 1/0.0625 = 16
, you could convert it by multiplying by 16:
18.25 * 16 = 292 = 0124h = 0000 0001 0010 0010
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论