在十六进制和二进制表示法之间移动 [英] Moving between hexadecimal and binary notation

查看:180
本文介绍了在十六进制和二进制表示法之间移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当一个字节用二进制表示的8位表示时,你有一个8个可能的1和0的序列。所以00101010可以用十六进制符号缩短到2A。我的书说你可以在右边第四位之后用十六进制缩短表示。例如... ...



00101010
可以用十六进制符号和二进制符号的混合表示取左边0010的4位数字和以16进制数表示该序列的2位数。

因为0010等于32,所以当你使用十六进制表示法时,其基数为16,等于2.



我不知道不明白的是序列的右侧如何表示。我的书说1010可以用等于10的字母A表示。以二进制表示法1010等于8 + 2 = 10.这是我遇到的问题。

将相同的概念应用于8位序列的左侧,不应该将乘车侧10乘以2,因为二
进制符号使用2的幂,就像你将左侧由于您使用16进制的十六进制符号,所以边数为16?我在想这个错吗?

解决方案

让我们从完整的8位字节开始,在每个数字下面写下位置值:

  0 0 1 0 1 0 1 0 
↓↓↓↓↓↓↓↓
↓↓↓↓8 4 2 1
↓↓↓16
↓↓32
↓64
128


$ b $如果我们将8位字节分成两个4位的低位字节,那么在基数10中,这是32 + 8 + 2 = 42。

您有

$ $ p $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ 8 4 2 1 8 4 2 1

您会注意到每个4位nybble都可以保存一个值因此nybbles可以表示两个十六进制数字。



当我们计算它们的值时,我们以相同的方式处理这两个nybbles。从左到右,每个nybble中的数字的值为8,4,2,1。因此,上(左)nybble的值为2,下(右)nybble的值为8 + 2 = 10正如你写的,十进制数10写成十六进制的A,所以十六进制字节写成 2A



<但请记住,这是十六进制的。所以地点价值是16的权力:

  2 A 
↓↓
↓1
16

所以,转换回十进制,2A = 2× 16 + 10 = 32 + 10 = 42。

When one byte is represented by 8 bits in binary notation you have a sequence of 8 possible 1's and 0's. So 00101010 can be shortened to 2A using hexadecimal notation. My book says you can shorten that representation by using hexadecimal after the 4th place from the right. For example...

00101010

can be represented with a mix of hexadecimal notation and binary notation by taking the 4 digits on the left 0010 and and representing that sequence to equal 2 in hexadecimal. I understand because 0010 equals 32 and when you are using hexadecimal notation that has a base of 16 that equals to 2.

What I don't understand is how the right side of the sequence is represented. My book says 1010 can be represented by the letter A which equals to 10. 1010 in binary notation equals 8 + 2 = 10. Here is the issue I'm having.

Applying the same concept to the right side as the left side of the 8 bit sequence shouldn't you divide the ride side 10 by 2 since binary notation is using the power of 2 like you divided the left side by 16 since you're using hexadecimal notation which has the power of 16? Am i thinking about it wrong?

解决方案

Let's start with the complete 8-bit byte, writing the place value under each digit:

0 0 1 0 1 0 1 0
↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
↓ ↓ ↓ ↓ 8 4 2 1
↓ ↓ ↓ 16
↓ ↓ 32
↓ 64
128

So, in base 10, this is 32 + 8 + 2 = 42.

If we split the 8-bit byte into two 4-bit nybbles, you have

0 0 1 0  1 0 1 0
↓ ↓ ↓ ↓  ↓ ↓ ↓ ↓
8 4 2 1  8 4 2 1

You'll notice each 4-bit nybble can hold a value from 0 to 15. So the nybbles can represent two hexadecimal digits.

We treat the two nybbles the same way when we calculate their values. From left to right, the digits in each nybble have place values 8, 4, 2, 1. So the upper (left) nybble has a value of 2, and the lower (right) nybble has a value of 8 + 2 = 10. As you wrote, the decimal number 10 is written as A in hexadecimal, so the hexadecimal byte is written 2A.

Remember, though, that this is hexadecimal. So the places values are powers of 16:

2 A
↓ ↓
↓ 1
16

So, converting back to decimal, 2A = 2×16 + 10 = 32 + 10 = 42.

这篇关于在十六进制和二进制表示法之间移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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