为什么内存地址使用十六进制数字表示? [英] Why are memory addresses are represented using hexadecimal numbers?
问题描述
例如:
*(0x12DF)
我想知道为什么内存地址用十六进制数表示?
是否有一个特殊的原因,或者它只是一个约定?
单位,例如页面或段,
的大小往往是2的幂。因此,如果地址以十六进制表示,则
更容易将它们读为页面+偏移量或类似结构。十进制是困难的,因为麻烦的因素是5美元的
,而二进制地址太长而不易读。
Whenever I see C programs that refer directly to a specific location on the memory (e.g. a memory barrier) it is done with hexadecimal numbers, also in windows when you get a segfualt it presents the memory being segfualted with a hexadecimal number.
For example: *(0x12DF)
I am wondering why memory addresses are represented using hexadecimal numbers?
Is there a special reason for that or is it just a convention?
Memory is often manipulated in terms of larger units, such as pages or segments, which tend to have sizes that are powers of 2. So if addresses are expressed in hex, it's much easier to read them as page+offset or similar constructs. Decimal is difficult because of that pesky factor of 5, and binary addresses are too long to be easily readable.
这篇关于为什么内存地址使用十六进制数字表示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!