Why are memory addresses are represented using hexadecimal numbers?

26,078

Solution 1

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.

Solution 2

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.

Solution 3

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.)

Solution 4

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

Share:
26,078
the_drow
Author by

the_drow

My name is Omer Katz and I am a very passionate software developer who specializes in ALM & SCM practices. I'm also an Agile & Lean enthusiast and practitioner. I am only 23, therefor I have only started working in the industry in 2010 but I have been programming since I was 11 and I have never stopped being passionate about it. I have a vast knowledge when it comes to planning, designing, developing & delivering software. My greatest passion is finding new ways to make the developers' lives easier and let them focus on what they know to do best, software development.

Updated on March 25, 2020

Comments

  • the_drow
    the_drow about 4 years

    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?

  • supercat
    supercat over 12 years
    It's worth noting that even in systems without any concept of virtual memory, hardware itself has for a very long time almost always divided memory into regions whose sizes and boundaries are either powers of two or small multiples thereof (e.g. a standard VIC-20 had 8-bit RAM from 0x0000-0x03FF and 0x1000-0x1FFF, and 4-bit RAM from 0x9400-0x97FF).
  • glglgl
    glglgl over 9 years
    Even Base32 is shorter, but the advantage of hex is that one digit is exactly half of an octet.
  • 8bittree
    8bittree about 7 years
    The ease of conversion in hardware or software has nothing to do with it; it's trivial regardless of base. The use of hexadecimal (or octal) is for the ease of conversion by humans and pattern recognition by humans.
  • ilansch
    ilansch almost 7 years
    Why do you mean "Decimal is difficult because of that pesky factor of 5" ? conversion between base 10 and base 2 ?