Menu
Coddy logo textTech

Numbers as Bits

Lesson 1 of 46 in Coddy's IP Addressing and Subnetting course.

Every IP address is, underneath, just numbers stored as bits: switches that are either 0 or 1. Eight bits together make a byte, and a byte can hold any number from 0 to 255.

Each position in a byte has a value: 128 64 32 16 8 4 2 1, from left to right. A number is written by switching on the positions that add up to it. For example, 172 is 10101100 because 128 + 32 + 8 + 4 = 172.

Subnetting is binary arithmetic in disguise. Get comfortable turning a decimal number into its bits and the whole topic becomes simple bookkeeping.

challenge icon

Challenge

Beginner

Convert the number 172 to 8-bit binary by hand: start at 128 and work down, switching on each position that fits. Then print your answer with echo.

Expected output:

10101100

Try it yourself

Terminal

All lessons in IP Addressing and Subnetting

Practice on your own: Terminal playground