为什么内存地址使用十六进制数字表示? [英] Why are memory addresses are represented using hexadecimal numbers?

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

问题描述

每当我看到直接指向内存中特定位置的C程序(例如内存屏障)时,它会用十六进制数字完成,在窗口中当您获得一个segfualt时,它会显示内存被十六进制数字分隔。

例如: *(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屋!

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