BeginnerTopic 35 of 104Electronics & Embedded

Number conversions

Convert among binary, octal, decimal and hexadecimal.

In depth

Decimal to binary: repeatedly divide by 2 and collect remainders. Binary to hex: group by four. Fractions: multiply by 2. BCD encodes each decimal digit in 4 bits. Know powers of two to speed conversions.

Key points

  • 0xFF = 255
  • Octal groups of three bits
  • ASCII codes characters
Example

Decimal 45 = 101101₂ = 0x2D.

Why it matters

Hexadecimal is compact and maps neatly onto bytes, so it is the standard way to read memory dumps, colours and register values.

Where this is used

  • Reading a register map in a microcontroller datasheet.
  • Writing a colour value as a six-digit hex code for a display.
  • Checking a memory dump during debugging.

Frequently asked questions

What is Number conversions?

Convert among binary, octal, decimal and hexadecimal.

Why is it important to understand number conversions?

Hexadecimal is compact and maps neatly onto bytes, so it is the standard way to read memory dumps, colours and register values.

Why use hexadecimal?

Each hex digit represents exactly four bits, so a byte is two hex digits, which makes long binary numbers short and readable.

How do I convert hex to decimal?

Multiply each digit by a power of sixteen and sum the results, such as 0x1F equals 1 times 16 plus 15 for 31.

How is Number conversions used in practice?

Typical applications include reading a register map in a microcontroller datasheet, writing a colour value as a six-digit hex code for a display and checking a memory dump during debugging.

What should I learn before Number conversions?

Study "Binary numbers" first (topic 34 of 104 in Electronics & Embedded). It covers the groundwork this topic builds on.

What are the key points of Number conversions?

0xFF = 255. Octal groups of three bits. ASCII codes characters.

Can you give an example of Number conversions?

Decimal 45 = 101101₂ = 0x2D.

What comes after Number conversions?

The next topic is "Two's complement", which builds directly on this one.

How difficult is Number conversions?

It is classed as Beginner in Electronics & Embedded (topic 35 of 104). It is an entry-level topic. It relies only on basic school mathematics and the ideas introduced earlier in this discipline.

Learning path

Want to practise? Open the interactive course for quick checks, quizzes, simulations and progress tracking.

Related topics