So we use hexadecimal which has the advantage of going up to 15 in single digits A-F, but why is it an issue that it takes 2 digits to represent the number 10 in decimal?

I was reading up about hexadecimal and I came across these 2 lines:

Base 16 suggests the digits 0 to 15, but the problem we face is that it requires 2 digits to represent 10 to 15. Hexadecimal solves this problem by using the letters A to F.

My question is, why should we care how many digits it takes to represent a number? - Is it slower for the computer to deal with a number with 2 digits compared to 1?

closed as unclear what you're asking by GlenH7, Robert Harvey, GrandmasterB, Caleb, Dan Pichelman May 27 '14 at 23:39

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 4
    Can you provide the context around the quote and where you found it? – DFord May 27 '14 at 16:43
  • 4
    2 digits makes 10 ambigious. Does 10 mean (1 * 16) + 0 or 10 * 1? – Mike May 27 '14 at 16:46
  • 1
    The simple answer is because digital electronics work with number systems that use binary and/or multiples of 2 much more efficiently than oddball numbering systems (like base-10). Go implement a full adder circuit that works with base-16 and base-10 and compare the complexity. Also, by using only 10 of 16 possible values that your bits can represent, you've just reduced your usable memory by 37.5%. So your 1 Terabyte hard-drive has just turned into just a 630 MB drive. Your 4 GB of RAM has just turned into 2.5 GB of RAM. It might not be a big deal to you, but to most people it is. – Dunk May 27 '14 at 22:31
  • 3
    You've got some fundamental misunderstandings about digits and how computers work. The representation we see is for our convince. I would suggest stoping by Software Engineering Chat at some point where we could work through some of these misunderstandings (it requires a bit of back and forth to make sure the various bits (pun intended) are understood correctly). – user40980 May 29 '14 at 2:44
  • 3
    Hexadecimal is a human representation, not a computer one. That's one of your invalid assumptions. It's a convenient way to express bytes in four-bit heximal places, that's all. The reason we don't use two digits per heximal place is because that would be really, really confusing. – Robert Harvey May 29 '14 at 2:54

Because 15 was the maximum value of a "word" at one point in time. A "word" refers to (among many other things over the years) the number of bits that a CPU is designed to operate on as a single thing. 4 bits toggled 1111 makes the binary value of 15.

Hexadecimal was created with the explicit purpose of being able to dictate in a single character, the value of a word of memory. With one character you can dictate what is a binary value between 0000 and 1111 which is the full range of a word at the time when it became common place to use.

Nowadays hexadecimal is typically seen in 8 bit groups, thus 8 bits being 2 hexadecimal values you usually see hexadecimal in pairs ranging from 0x00 to denote zero, or 0xFF to denote 255 (the greatest value that can be held in 8 binary digits) etc. These pairs are refered to as octets, named so because they refer to the value of 8 bits.

  • 4
    I don't think that's what he's asking. What he's asking he's asking because he doesn't understand that, in any given base, one digit should encompass all of the values in a particular heximal place, and the use of decimal will not accomplish that. – Robert Harvey May 27 '14 at 16:50
  • 1
    @RobertHarvey I read the question as him being unclear why "15" is a useful number and why one should care that it takes one character or two characters to present it. I tried to explain the purpose of having a single character stand in for values up to 15... but you're right, it is unclear so I may be off. I'm going to VTC as such. – Jimmy Hoffa May 27 '14 at 16:52
  • @JimmyHoffa - Ah ha okie, i think that answers my question, thanks! – Crizly May 27 '14 at 16:56
  • @JimmyHoffa: [shrugs] – Robert Harvey May 27 '14 at 16:56
  • I would add that it follows from your answer that any word size must be a power of two. It makes no sense to use base 10 with computers when they use base 2: base 16 is a good compromise that can easily express base 2 in a human-friendly way while allowing us to determine the value of any given bit from a single hexadecimal digit. It is also very concise compared either to base 2 or to base 10. – user22815 May 27 '14 at 18:43

It's an awkward way to phrase it, but it's only a "problem" when you're trying to write hexadecimal numbers. It's not a problem in decimal. If you used 10 instead of A in hexadecimal, then 100 could be parsed as 1 0 0 or 10 0, which are two very different numbers. You would need some other means of separating the digits. One character per digit avoids that issue.


Without knowing the full context of the statement this is a little speculative, but, the author is likely noting that hexadecimal is just one implementation of Base 16.

In a Base 16 schema, you need 16 symbols. We're already familiar with 10 such symbols in decimal that we can easily "reuse" without confusing ourselves. So, in the hexadecimal implementation of Base 16, we solve the "problem" of the missing 6 symbols by adding A through F to our numeric symbol set.

  • 2
    "Hexadecimal" literally just means "16". It's another term for base 16. The one implementation you refer to is representation using [0-9A-F] as digits. – user7043 May 27 '14 at 16:58
  • 2
    @delnan It's distinct from "base 16" though. And when we say "hexadecimal" in CS, we don't mean "16." ... We mean "0 through F." Greek aside, we're referring to an implementation of a base-16 number system. – svidgen May 27 '14 at 17:01
  • Of course we don't use it as synonym for "16", we have a perfectly good term for that already, we mean "base 16" (same for decimal vs. base 10). Because we also mean 0..F when we say "base 16". Implementations using other digits are isomorphic, and not canonical, therefore usually not worth consideration (except when teaching people about the difference between value and representation). We rarely talk about "abstract base 16" without thinking of 0.. because we don't need to. – user7043 May 27 '14 at 17:24
  • @delnan In a strictly CS and/or "western" context, I'd usually agree with you if I understand your complaint. In the context of the quote in question (from the OP), it seems clear that "Base 16" is being referred abstractly (or at least distinctly from it's hexadecimal implementation). – svidgen May 27 '14 at 18:51
  • Just to muddy the waters further, a historical Greek hexadecimal system would use alpha, beta, gamma, delta, epsilon, zeta, eta, theta, iota, kappa, lambda, mu, nu, xi, omicron, and pi, as the digits. None of them newfangled Hindu-Arabic digits for the ancient Greeks! – Ross Patterson May 29 '14 at 2:26

When it's an issue, it's because it causes a mismatch between the memory required to store a value and the memory required to display a value.

Take HTML color codes, for example. Each of the three red, blue, and green values has an integer value between 0 and 255. In memory, this is represented as a single 8 bit value, with all of the values from 00 to FF requiring the same amount of memory to store or write. Having two digits lets the text parser be very specific on the format, while keeping the number of characters needed at a minimum. Hexadecimal also exactly matches to numeric memory allocations; a single digit equals a single 4-bit value, two digits equal an eight-bit value, and so on.

Not the answer you're looking for? Browse other questions tagged or ask your own question.