为什么以及何时使用十六进制值 [英] why and when to use hex values

查看:159
本文介绍了为什么以及何时使用十六进制值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ivé看到一些代码,其中程序员使用十六进制值,如字节b1 = 0xf7等而不是简单的十进制值。当我们应该使用十进制值而不是十进制时,是否有任何理由可以使用十进制值而非十进制值条件?

ivé seen some codes where programmers use hex values like byte b1=0xf7 and so on instead of plain decimal values.when should we use hex values over decimal and is there any good reason why one should use hex values over decimal in such condition?

推荐答案

一般没有区别。这主要是历史性的事情。可以产生(轻微)差异的一个地方是定义要在位图中使用的值或用于颜色的值(#123456),其中读者应该能够看到哪些位在哪里。在其他地方,比如ASCII值,它可能更属于传统。
There is generally no difference. It's mostly a historical thing. One place where it can make a (slight) difference is when defining values to be used in bitmaps or values to be used for colors (#123456) where the reader should be able to see which bits go where. In other places, like ASCII values, it can be more a matter of tradition.


这篇关于为什么以及何时使用十六进制值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆