Why are memory addresses are represented using hexadecimal numbers?

后端 未结 5 1957
既然无缘
既然无缘 2020-12-13 05:21

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

相关标签:
5条回答
  • 2020-12-13 06:02

    It's the shortest, common number format, thus the numbers don't take up much place and everybody knows what they mean.

    0 讨论(0)
  • 2020-12-13 06:07

    Computer only understands binary language which is collection of 0's and 1's. That means ON/OFF. As in case of the human readability the binary number which may be representing some address or data has to be converted into human readable format. Hexadecimal is one of them. But the question can be why we have converted binary to HEX only why not decimal, octal etc. Answer is HEX is the one which can be easily converted with the least amount of overhead on both HW as well as SW. thats why we are using addresses as HEX. But internally they are used as binary only.

    Hope it helps :)

    0 讨论(0)
  • 2020-12-13 06:10

    Convention and convenience: hex shows more clearly what relationship various pointers have to address segmenting. (For example, shared libraries are usually loaded on even hex boundaries, and the data segment likewise is on an even boundary.) DEC minicomputer convention actually preferred octal, but IBM's hex preference won out in practice.

    (As for why this matters: what's easier to remember, 0xb73eb000 or 3074338816? It's the address of one of the shared objects in my current shell on jinx.)

    0 讨论(0)
  • 2020-12-13 06:19

    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.

    0 讨论(0)
  • 2020-12-13 06:20

    Its a much shorter way to represent what would otherwise be written in binary. It is also very nice and easy to convert hex to binary and back. Each 4 digits of binary corresponds to one digit of hex.

    0 讨论(0)
提交回复
热议问题