为什么DWORD值通常用十六进制表示? [英] Why are DWORD values commonly represented in Hexadecimal?

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

问题描述



我试图理解为什么DWORD值通常在MSDN上的十六进制中描述。我为什么要分析这是因为我想从根本上理解为什么所有这些不同的数字数据类型存在。一个本地导师向我指出,创建DWORD和其他Microsoft类型与处理器的演变有关。这给我的理解这些数据类型的意义和上下文。我想要更多的上下文和背景。



无论如何,我可以使用一些解释或一些资源,如何记住DWORD,无符号整数,字节,位, WORD等。



总之,我的问题是:
1)为什么DWORD以Hex表示?
2)您能提供数字数据类型之间的差异及其创建原因的资源吗?

解决方案

一台电脑是一堆0s和1s。但是用二进制写一个整个DWORD是相当乏味的:

  00000000 11111111 00000000 11111111 

以节省空间和提高可读性,我们喜欢以较短的形式写它。十进制是我们最熟悉的,但不能很好地映射到二进制。八进制和十六进制映射相当方便,正好与二进制位排列:

  //每个八进制数字正好是3个二进制数字
01 010 100 binary = 124 octal

//每个十六进制数字正好是4个二进制数字
0101 0100 binary = 54十六进制

由于十六进制字符串非常好地与8位字节(2个十六进制数字使一个字节),符号卡住,这是最常用的。



标识正在使用的碱基的正常速记:

  1234543 = decimal 
01234543 = octal(前导零)
0x1234543 =十六进制(以0x开头)

至于有关BYTE,WORD,DWORD等问题...



计算机开始有点。只有1或0。他在原来的Tron中有一个子机。



字节是8位长(好,一次有7位字节,可以忽略它们)。这允许你有一个从0-255的数字,或一个有符号的数字从-128到127.比只是1/0,但仍然有限。你可能听说过8位游戏。这就是我们所说的。系统是围绕Bytes建造的。



然后计算机增长到16位寄存器。这是2字节,并被称为一个字(不,我不知道为什么)。现在,数字可能是0-65535或-32768到32767。



我们继续想要更多的电源,计算机扩展到32位寄存器。 4字节,2字,也称为DWORD(双字)。到这一天,你可以在C:\ Windows中查看系统(旧的16位段)和system32(新的32位组件)的目录。



然后是QWORD(四字)。 4字节,8字节,64位。听说任天堂64?这就是名字来自的地方。现代建筑现在在这里。 cpu的内部包含64位寄存器。您通常可以在此类cpus上运行32位或64位操作系统。



包括位,字节,字,双字。这些是原始类型,常用于标志,位掩码等。如果要保存实际数字,最好使用signed / unsigned integer,long等。



我没有涵盖浮点数,但希望这有助于一般的想法。


I am trying to understand why a DWORD value is often described in Hexadecimal on MSDN.

The reason why I am analyzing this is because I am trying to understand fundamentally why all these different number data types exist. A local mentor alluded to me that the creation of DWORD and other Microsoft types had something to do with the evolution of processors. This gives meaning and context to my understanding of these data types. I would like more context and background.

Either way, I could use some explanation or some resources on how to remember the difference between DWORD, unsigned integers, bytes, bits, WORD, etc.

In summary, my questions are: 1) Why are DWORDs represented in Hex? 2) Can you provide resources on the differences between numerical data types and why they were created?

解决方案

Everything within a computer is a bunch of 0s and 1s. But writing an entire DWORD in binary is quite tedious:

00000000 11111111 00000000 11111111

to save space and improve readability, we like to write it in a shorter form. Decimal is what we're most familiar with, but doesn't map well to binary. Octal and Hexadecimal map quite conveniently, lining up exactly with the binary bits:

// each octal digit is exactly 3 binary digits
01 010 100 binary  =  124 octal

// each hexadecimal digit is exactly 4 binary digits
0101 0100 binary   =  54 hexadecimal

Since hex lines up very nicely with 8-bit Bytes (2 hex digits make a Byte), the notation stuck, and that's what gets used most. It's easier to read, easier to understand, easier to line up when messing around with bitmasks.

The normal shorthand for identifying which base is being used:

  1234543 = decimal
 01234543 = octal (leading zero)
0x1234543 = hexadecimal (starts with 0x)

As for your question about BYTE, WORD, DWORD, etc...

Computers started with a bit. Only 1 or 0. He had a cameo in the original Tron.

Bytes are 8 bits long (well, once upon a time there were 7-bit bytes, but we can ignore those). This allows you to have a number from 0-255, or a signed number from -128 to 127. Better than just 1/0, but still limited. You may have heard references to "8-bit gaming". This is what we refer to. The system was built around Bytes.

Then computers grew to have 16-bit registers. This is 2 Bytes, and became known as a WORD (no, I don't know why). Now, numbers could be 0-65535 or -32768 to 32767.

We continued to want more power, and computers were expanded to 32-bit registers. 4 Bytes, 2 Words, also known as a DWORD (double-word). To this day, you can look in "C:\Windows" and see a directory for "system" (old 16-bit pieces) and "system32" (new 32-bit components).

Then came the QWORD (quad-word). 4 WORDS, 8 Bytes, 64 bits. Ever hear of the Nintendo-64? That's where the name came from. Modern architecture is now here. The internals of the cpu contain 64-bit registers. You can generally run a 32- or 64-bit operating system on such cpus.

That covers Bit, Byte, Word, Dword. Those are raw types, and are used often for flags, bitmasks, etc. If you want to hold an actual number, it's best to use signed/unsigned integer, long, etc.

I didn't cover floating point numbers, but hopefully this helps with the general idea.

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

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