The convenient way for converting from dec to hex

本文介绍了如何将二进制形式的数值转换为十六进制表示法,特别是当数值为2的幂次时的方法。通过举例说明了具体的转换过程。

       When a value x is a power of two, that is, x = 2 ^ n for some nonnegative integer n,

we can readily write x in hexadecimal form by remembering that the binary representation

of x is simply 1 followed by n zeros. The hexadecimal digit 0 represents four binary zeros.

So, for n written in the form i + 4j, where 0 <= i <= 3, we can write x with a leading hex digit

of 1(i = 0), 2(i = 1), 4(i = 2), or 8(i = 3), followed by j hexadecimal 0s. As an example, for

x = 2048 = 2 ^11, we have n = 11 = 3 + 4 * 2, giving hexadecimal representation 0x800.


                             ---------- From  Computer System A Programmer's Perspective Page 35



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值