CalculateeLearning paths
Digital Electronics8–10 min read

Binary, Hexadecimal and Signed Numbers

Read register values and convert between binary, hexadecimal and signed representations.

Mental model

The same quantity can be written with different alphabets. Binary uses two symbols, hexadecimal sixteen; the bit pattern needs a type to tell you what it means.

101100101011₂ = B₁₆0010₂ = 2₁₆1011 0010₂ = 0xB2
Each group of four binary bits maps directly to one hexadecimal digit.
UNDERSTAND THE BEHAVIOR
01

Each binary position has a power-of-two weight. Starting from the right, those weights are 1, 2, 4, 8 and so on. Add the weights where the bit is one. Hexadecimal groups four bits into one digit, so a byte becomes two hex digits. This makes long register patterns easier to read without changing the underlying bits.

02

An unsigned n-bit value ranges from zero to 2ⁿ − 1. Eight bits therefore represent 0 through 255. Leading zeros do not change the value but do make the width visible. Width matters when a register has a fixed number of bits or a message reserves exactly two bytes for a field.

03

In an n-bit two's-complement interpretation, the highest bit has weight −2ⁿ⁻¹. The range becomes −2ⁿ⁻¹ through 2ⁿ⁻¹ − 1. Thus 11111111 means 255 as an unsigned byte and −1 as an eight-bit two's-complement signed value. The bits alone do not identify the interpretation; the type or protocol does.

04

Endianness describes the order of bytes in a multi-byte value, not the order of decimal digits in a printed number. Sending 0x1234 as little-endian produces byte 0x34 followed by 0x12. Specify byte order explicitly when exchanging data instead of copying a memory representation and hoping the receiver matches.

Why it matters

Read register values and convert between binary, hexadecimal and signed representations.

Core ideas

  • Four binary bits correspond to one hex digit.
  • A bit pattern needs a width and interpretation.
  • Specify byte order in communication formats.
Key equationsUnsigned range: 0 … 2ⁿ − 1Two's-complement range: −2ⁿ⁻¹ … 2ⁿ⁻¹ − 1
EXAMPLE

Work through a practical example

1Split binary 10110110 into 1011 and 0110.

2These groups are hexadecimal B and 6, giving 0xB6.

3Unsigned decimal value is 128 + 32 + 16 + 4 + 2 = 182.

4As signed eight-bit two's complement, subtract 256: 182 − 256 = −74.

Common mistake

Assuming 0xFF always means −1 or always means 255 without checking the type.

RememberFour binary bits correspond to one hex digit.

Practice and check your understanding

Try each question before opening the worked answer.

1. What is 0x2A in decimal?

Show answer and reasoning

2 × 16 + 10 = 42.

2. Which two bytes encode 0x1234 in big-endian order?

Show answer and reasoning

0x12 then 0x34: most significant byte first.

Continue learning

Technical references and further reading

References are for further study, not endorsements. Report an error or suggest an improvement.

Progress stays on this browser only. Clearing site data removes it; it does not sync across devices.