100%
GRIMOIRE
GrimoireDindon CorpusSynthesis VolumesThe Foundation of Iron
FRENAR
← PreviousNext →
RATIO
THE FOUNDATION OF IRON · COURSE MATERIAL · WEEK 2
◆◆◆
NUMBER-BASE
CONVERSION
Week 2 of 26 · Block 1 — Fundamentals
15h theory · 20h practice
◆ WEEKLY LEARNING OBJECTIVES

1. Convert a number between binary, octal, decimal and hexadecimal
2. Perform the 4 basic arithmetic operations in each numbering system
3. Understand the relationship between bit, byte and physical representation (electrical pulse)
4. Calculate an IP address and a subnet mask in binary
5. Convert a hexadecimal colour code and understand its structure

◆◆◆
NOTE FOR THE INSTRUCTOR

The theory section of this material is a structured course outline — key concepts, calculation methods, worked examples — meant to serve as a guiding thread that the instructor develops orally. The practical exercises and their solutions are written in full and stand on their own.

Amine RAITI · Infrastructure Architect & SRE
Public document · CC BY-NC-SA 4.0 · AI Powered by Amine
Opération Dindon
RATIO
COURSE OUTLINE · 15H
THEORY GUIDING THREAD
2.1 · Why binary — from bit to electrical pulse2h
— Recap from Week 1: a bit corresponds to an electrical state (presence/absence of voltage)
— Direct link between binary logic and the physical reality of circuits
— The bit as the fundamental unit, the byte as a group of 8 bits (256 possible values)
2.2 · The binary system — principles and conversion3h
— Positional principle in base 2 (powers of 2)
— Decimal-to-binary conversion method (successive division by 2)
— Binary-to-decimal conversion method (sum of activated powers of 2)
— Example to work through: 156 in decimal → binary, and reverse verification
2.3 · The hexadecimal system3h
— Why hexadecimal exists: compactness for representing bytes (2 hex characters = 1 byte)
— Binary/hexadecimal correspondence table by groups of 4 bits
— Decimal ↔ hexadecimal conversion method
— Example to work through: memory address 0x1F4 → decimal (500)
2.4 · The octal system and arithmetic in non-decimal bases2h
— Positional principle in base 8, historical use (Unix chmod permissions)
— Binary addition and subtraction (carry and borrow)
— Example to work through: binary addition 1011 + 0110
EXAMPLE TO DEVELOP ON THE BOARD

A Unix chmod 755 permission breaks down in binary by groups of 3 bits: 7 = 111 (rwx), 5 = 101 (r-x), 5 = 101 (r-x) — owner has read/write/execute, group and others have read/execute only.

RATIO
COURSE OUTLINE · 15H · APPLICATIONS
GUIDING THREAD — NETWORKING AND COLOUR APPLICATIONS
2.5 · IP addressing in binary3h
— An IPv4 address = 4 octets = 32 bits, each octet converted to decimal for the usual notation
— Example to work through: convert 192.168.1.10 entirely to binary (octet by octet)
— Direct link with the binary covered in 2.2 — no new concept, just an application
2.6 · Subnet masks2h
— The mask defines the boundary between network and host portions in binary
— CIDR notation (/24, /16, etc.) = number of 1-bits in the mask
— Example to work through: /24 mask = 255.255.255.0 = 11111111.11111111.11111111.00000000
2.7 · Hexadecimal colours2h
— A web colour #RRGGBB = 3 hexadecimal bytes (red, green, blue)
— Example to work through: break down #1A5FA8 into its 3 decimal components (26, 95, 168)
— Link with the byte concept from 2.1 — each colour component is one byte
Key definitions to fix before the practical exercises

Bit: elementary binary unit (0 or 1), corresponding to an electrical state.
Byte: group of 8 bits, 256 possible values (0 to 255 in decimal).
CIDR notation: number of consecutive 1-bits in a subnet mask (e.g. /24).
Hexadecimal: base-16 system, using digits 0-9 and letters A-F.

RATIO
EXERCISE 1 · MANUAL BASE CONVERSIONS · 7H

Equipment: provided exercise sheet (20 numbers to convert), no calculator allowed for this part — the goal is mastering the manual method.

(2h) Decimal-to-binary conversion of 5 numbers (values between 10 and 255), successive division by 2 method, verified by reverse binary-to-decimal conversion.
(2h) Decimal-to-hexadecimal conversion of 5 numbers, successive division by 16 method, verified by reverse conversion.
(1h30) Direct binary-to-hexadecimal conversion by grouping 4 bits, on 5 provided binary numbers (8 to 16 bits).
(1h30) Addition of 2 binary numbers with carry, on 5 provided pairs of numbers (4 to 8 bits each).
SOLUTION — EXERCISE 1

Example decimal-to-binary conversion (156): 156÷2=78 remainder 0; 78÷2=39 remainder 0; 39÷2=19 remainder 1; 19÷2=9 remainder 1; 9÷2=4 remainder 1; 4÷2=2 remainder 0; 2÷2=1 remainder 0; 1÷2=0 remainder 1. Reading the remainders bottom to top: 10011100.

Verification: 10011100 = 128+16+8+4 = 156. ✓

Example decimal-to-hexadecimal conversion (500): 500÷16=31 remainder 4; 31÷16=1 remainder 15(F); 1÷16=0 remainder 1. Reading bottom to top: 0x1F4.

Example binary addition (1011 + 0110): column by column from right to left with carry: 1+0=1; 1+1=10 (write 0, carry 1); 0+1+1(carry)=10 (write 0, carry 1); 1+0+1(carry)=10 (write 0, carry 1) → result 10001 (=17 in decimal, verification: 11+6=17 ✓).

RATIO
EXERCISE 2 · IP ADDRESSING AND SUBNET MASKS · 7H

Equipment: provided exercise sheet (5 IP addresses with various CIDR masks), calculator allowed for this part.

(2h) Full conversion of 5 IPv4 addresses to binary, octet by octet (e.g. 192.168.1.10 → 4 groups of 8 bits).
(2h) For each address, conversion of the given CIDR mask (/24, /16, /28, etc.) to dotted-decimal notation.
(2h) Calculating the network address and broadcast address for each address/mask pair, via binary operation (logical AND with the mask for the network address).
(1h) Calculating the number of usable addresses in each subnet (2^(number of host bits) - 2).
SOLUTION — EXERCISE 2

Full example — address 192.168.1.10 / 24:

Binary conversion: 192=11000000, 168=10101000, 1=00000001, 10=00001010.
Mask /24 = 11111111.11111111.11111111.00000000 = 255.255.255.0.

Network address (logical AND of address/mask): 192.168.1.0.
Broadcast address: 192.168.1.255.
Number of usable addresses: 2^8 - 2 = 254 addresses (256 possible, minus the network address and the broadcast address).

Example with a /28 mask: 2^4 - 2 = 14 usable addresses only, which concretely illustrates the direct impact of the mask choice on subnet size — an essential point for the DHCP module later in the programme.

RATIO
EXERCISE 3 · HEXADECIMAL COLOUR CONVERSION · 6H

Equipment: provided exercise sheet (5 hexadecimal colour codes and 5 decimal RGB values to convert both ways), digital colour picker for visual verification.

(2h) Breaking down 5 hexadecimal colours (#RRGGBB) into their 3 decimal components (R, G, B).
(2h) Reverse conversion: from 5 decimal RGB triplets, reconstructing the corresponding hexadecimal code.
(2h) Visual verification of each conversion using a digital colour picker, and discussion of practical use (CSS, monitoring interface configuration).
SOLUTION — EXERCISE 3

Example — breaking down #1A5FA8: 1A (hex) = 26 (decimal), 5F (hex) = 95 (decimal), A8 (hex) = 168 (decimal). RGB(26, 95, 168) — a deep blue commonly used in technical brand guidelines.

Example — reconstructing from RGB(212, 175, 55): 212 → D4 (hex), 175 → AF (hex), 55 → 37 (hex). Final code: #D4AF37 (a gold colour).

◆ SUMMARY SHEET — WEEK 2 SELF-ASSESSMENT
1. I can convert a decimal number to binary by successive division.
2. I can convert a binary number to decimal by summing powers of 2.
3. I can convert between hexadecimal and decimal in both directions.
4. I can perform binary addition with carry handling.
5. I can convert a full IPv4 address to binary, octet by octet.
6. I can calculate the network and broadcast address from an IP address and a CIDR mask.
7. I can calculate the number of usable addresses in a given subnet.
8. I can break down and reconstruct a hexadecimal colour code.
← PreviousNext →