Base-2

Binary Number System

Binary uses only 0 and 1, making it the native language of digital systems. Every byte, flag, permission bit, and machine instruction starts from this idea.

By The End Of This Lesson

  • Read an unsigned byte by adding the weights of its active bits.
  • Build a binary representation of a decimal whole number by hand.
  • Explain the range of an unsigned byte and the role of leading zeros.

Why Binary Matters

Bits & Bytes

Storage and memory are measured in bytes, and each byte is just eight binary positions.

Permissions

Read, write, execute, flags, and masks are often toggled as individual binary states.

Networking

IPv4 masks, subnetting, and packet flags become much easier once binary place values make sense.

Low-Level Thinking

Binary helps explain how processors, memory, file formats, and encodings are represented under the hood.

Place Value

Each binary digit contributes based on its power of two. This four-bit example uses 10112; a full byte uses the eight weights shown below.

Eights

2 to the power of 3

Value:8

1 × 8 = 8

Fours

2 to the power of 2

Value:4

0 × 4 = 0

Twos

2 to the power of 1

Value:2

1 × 2 = 2

Ones

2 to the power of 0

Value:1

1 × 1 = 1

Example Breakdown

10112

1 × 8 + 0 × 4 + 1 × 2 + 1 × 1

8 + 0 + 2 + 1 = 1110

Why It Helps

A 1 includes its place value and a 0 contributes nothing. Add the included values to convert a binary number into decimal.

Worked Example: Decimal To Binary

To represent 42, work from the largest byte weight downwards. Neither 128 nor 64 fits. Include 32, leaving 10. Skip 16, include 8, then include 2. Put a 1 in those positions and a 0 in the others.

42 = 32 + 8 + 2

0010 10102 = 4210

Eight bits have 28 = 256 different patterns. As unsigned whole numbers these run from 0 to 255. The leading zeros in 00101010 keep the eight-bit width; 101010 has the same value. Binary itself is not limited to a byte: 256 requires nine bits.

Another method: repeated division by two

Divide 13 by two repeatedly, recording each whole-number quotient and remainder. Stop when the quotient is zero.

DivisionQuotientRemainder
13 ÷ 261
6 ÷ 230
3 ÷ 211
1 ÷ 201

Read the remainders from the bottom upwards: 1101. Check with place values: 8 + 4 + 1 = 13. The first remainder is the rightmost, least significant bit.

Decimal To Binary

Predict the bits first, then enter a whole decimal value from 0 to 255 to check its unsigned byte and hexadecimal forms.

Binary

00101010

Hex

2A

Decimal 42 is binary 00101010 and hexadecimal 2A.

Byte Weights

Each position in a byte represents a power of two.

2 to the power of 7

128

2 to the power of 6

64

2 to the power of 5

32

2 to the power of 4

16

2 to the power of 3

8

2 to the power of 2

4

2 to the power of 1

2

2 to the power of 0

1

Binary Quick Reference

DecimalBinaryHex
000000
100011
200102
300113
401004
501015
601106
701117
810008
910019
(10)1010A
(11)1011B
(12)1100C
(13)1101D
(14)1110E
(15)1111F

Practise Before Checking

Write the eight-bit patterns for 13, 64, and 170 on paper. For each answer, add the active weights back to decimal. Then use Binary Demo to test your predictions, or Build the Byte without a target hint.

Success means you can explain which weights you selected, as well as produce the right pattern. Next, groups of three bits become octal digits and groups of four become hexadecimal digits.

Check Your Understanding

Try these without the converter or reference table. Check each answer to reveal its explanation.

1. Which eight-bit pattern represents decimal 42?

Choose an answer before checking. You can change your choice and try again.

2. Can an unsigned eight-bit value represent decimal 256?

Choose an answer before checking. You can change your choice and try again.

3. How does 00001101 compare with 1101 as an unsigned number?

Choose an answer before checking. You can change your choice and try again.