2

I know most computer architecture store data in binary in drives/storage, but i'm unsure where in a computer (x86, etc) does the conversion/interpretation of binary (base2) to hexadecimal (base16) occur.

Is it by the Cpu? Motherboard? or is it made by many components (including software running)?

If so, which of those is the first to do that conversion/interpretation?

13
  • It's not very clear what you are asking. Data does not generally need to be converted from binary to hexadecimal except in some cases where hexadecimal human-readable (ASCII) output or a specific file output format is needed. In most cases this would be done by software running on the CPU, but in very simple computers it can also be done by simple hardware for display on a 7-segment display. It's a trivial task compared to binary->decimal conversion.
    – StarCat
    Commented Jul 1, 2020 at 10:42
  • 2
    I’m voting to close this question because it’s not specific to retro-computing; it would fit better on Stack Overflow. Commented Jul 1, 2020 at 11:10
  • it is specific to retro-computing, as the possible answers might mention older architecture and model that does/doesn't do this (as Michael Graf's answer provided ) @StephenKitt Commented Jul 1, 2020 at 11:12
  • 8
    No computer whatsoever works or needs data to be converted into hexadecimal. That's just a notation that enables us silly humans to read and write binary numbers more easily.
    – tofro
    Commented Jul 1, 2020 at 11:32
  • 1
    @Nordine saying “possible answers might mention older architecture” (sic) doesn’t make it specific to retro-computing. If it were specific to retro-computing, possible answers would only mention old architectures. Stack Overflow allows questions which ask for historical context too. Commented Jul 1, 2020 at 11:37

4 Answers 4

7

The smallest unit in a modern computer is the bit: it can either be 0 or 1, off or on, however you want to call its two states. That is: every modern computer works in base 2 (for integers; floating point numbers complicate things bu still use bits).

But displaying groups of bits to humans (even programmers) is tiresome, so some more convenient representations are chosen when showing those bit groups: the most common are base 8 (octal), base 10 (decimal) and base 16 (hexadecimal). Still, the computer does not know about hexadecimal, it's working with (groups of) bits. We call a processor's preferred group size of bits a word. For example, a 16-bit CPU prefers to do most or all of its operations on groups of 16 bits; no more, no less.

So the computer is working with base 2 numbers only. When you want to show the bit group to humans as a readable number, you need to format it. Which base you're using for the representation doesn't matter, this transformation from the internal value to a human-readable text representation is always done by the processor (CPU). Even when you want to show just the bit groups (base 2), some transformation to a text needs to be done.

To be more precise, this transformation from internal representation to text is done by software running on the CPU.

The mainboard/motherboard's function is to connect the CPU to all the input/output peripherals. Even though nowadays some parts of it do very complex operations/calculations, in the end it's not really taking part in the formatting of numbers other than providing a connection from the CPU to the graphics processor, which is going to display it, or some storage to save the representation.

So the complete answer to your question: "Which part of a computer does the conversion between binary and hexadecimal?" is: software running on the CPU, creating a representation that is passed to the graphics processor (usually via the mainboard) so you can see it on screen.

8

All modern computers use binary internally. (And by modern, I mean since 1960 or thereabouts.)

Hexadecimal (or octal, or decimal) are used only to make data more readable to humans. This conversion is normally done in software, converting e.g. a binary number to a string of ASCII characters that print as the hexadecimal representation of that number.

Software is executed in the CPU, so if you really want to assign this function to a piece of hardware, the conversion "is done by the CPU". There is, however, no dedicated part of the CPU for this; the CPU is just doing general arithmetic -- shifting bits, masking bits, adding something -- that gives the correct character value.

Some early 8-bit single-board computers did in fact have dedicated hardware, ususally as part of or in connection with seven segment displays. E.g., the COSMAC ELF used HP 5082 seven-segment-displays with integrated hexadecimal decoders.

6
  • 1
    so i take it it's done by the Cpu? (generally speaking) Commented Jul 1, 2020 at 10:50
  • @NordineLotfi No, you have taken it incorrectly, generally speaking, as the conversion would be done by external hardware such as the integrated decoders mentioned above (integrated into the display - not the CPU) or perhaps by standalone BCD to 7-Segment display decoders such as the 74c48.
    – Glen Yates
    Commented Jul 1, 2020 at 14:19
  • Reminds me of a retro project I started a few months ago. I wanted to use real binary-to-7-segment-hexadecimal ICs. About 6 such chips have been designed, and only one was still available for purchase today -- at $30 per hex digit! It is far cheaper to use a microcontroller instead for that purpose (and cheapest to do it in the host system's software).
    – DrSheldon
    Commented Jul 1, 2020 at 14:41
  • @DrSheldon You can get the the MC 14495 for significantly under a Dollar / Euro / Pound on AliExpress: aliexpress.com/af/… Commented Jul 1, 2020 at 15:49
  • @DrSheldon, Another option: Instead of programming an MCU, program a CPLD. digikey.com/product-detail/en/microchip-technology/… Commented Jul 1, 2020 at 15:52
4

Data does not generally need to be converted from binary to hexadecimal except in some cases where hexadecimal human-readable (ASCII) output or a specific file output format is needed.

In most cases this would be done by software running on the CPU, but in very simple computers it can also be done by simple (logic) ICs connected a 7-segment display.

It's a trivial task compared to binary->decimal conversion.

5
  • I see, so it's mostly done by the Cpu then? Commented Jul 1, 2020 at 10:49
  • On general-purpose computers, yes. On embedded/integrated hardware, not always.
    – StarCat
    Commented Jul 1, 2020 at 10:52
  • what does it in embedded/integrated hardware?(just for comparison since you mentioned it) Commented Jul 1, 2020 at 10:54
  • just need an example in case it would be too broad to answer when it come to embedded system :) Commented Jul 1, 2020 at 10:59
  • 2
    @NordineLotfi, re "mostly done by the Cpu." There is a sense in which you could say that the work is mostly done by the CPU, but knowing random facts is not the same thing as understanding. Knowing that any particular thing is "mostly done by the CPU" will not help you to understand where or when or why or how that thing is done. The only way you can understand it is by understanding the software that is in control of the CPU. Commented Jul 1, 2020 at 16:05
4

Hexadecimal notation is not very significant to how computers work. It is primarily just a convenient, compact way to represent the bits in a byte. For example, if I wanted to specify the exact contents of a byte storing the ASCII code for A, I could give the binary: 01000001 but that takes a while to type and is hard to remember. I could give the decimal value 65 but the conversion to and from binary is tricky for most humans (and gets worse if you are dealing with the bigger values of Unicode). The advantage of hexadecimal is that it easy to convert to and from binary: just break the bits into groups of 4 starting from the right and convert each separately. 01000001 becomes 41 which is easier to type and remember.

It is common to give the value of a byte (or larger section of memory) in hexadecimal but it does not really contain the hexadecimal any more than it contains the decimal number 65 or the letter A, it contains a bunch of bits. The hexadecimal notation is just a convenient shorthand.

The first computer that I used, an ICL 4120, used octal in place of hexadecimal since 6 bits had more significance that 8 (nothing special on that machine) and 6 bits can be neatly represented as two octal digits. For this reason, some programming languages have support for octal notation.

Not the answer you're looking for? Browse other questions tagged .