TutreNews Learn

Binary & Logic: How Computers Count and Decide

Understand bits and bytes, convert between decimal, binary and hexadecimal, add in binary, and build truth tables for AND, OR, NOT and XOR — the foundations of every digital circuit and every if-statement.

Beginner · 2 units · 7 lessons · 62 exercises · ~1 h

What you will learn

  • Explain place value in base 2 and base 16
  • Convert numbers between decimal, binary and hexadecimal
  • Add binary numbers and recognise overflow
  • Evaluate logical expressions with truth tables
  • Apply De Morgan's laws

Prerequisites

  • Whole-number arithmetic and powers

Learning path

1 Binary numbers

  1. Bits, bytes and place value8 min · 6 exercises
  2. Decimal to binary8 min · 6 exercises
  3. Hexadecimal9 min · 6 exercises
  4. Binary addition and overflow9 min · 6 exercises
  5. Unit exam6 exercises

2 Boolean logic

  1. AND, OR, NOT, XOR9 min · 6 exercises
  2. Combined expressions10 min · 7 exercises
  3. De Morgan's laws9 min · 5 exercises
  4. Unit exam5 exercises
  1. Final exam9 exercises

Practical project: Build a binary toolkit

  1. Write a function toBinary(n) in JavaScript or Python that uses the division method (no built-in conversion). Test it on 0, 1, 45, 255 and 1024.
  2. Write fromBinary(s) that adds place values. Check that fromBinary(toBinary(n)) === n for n = 0 … 1000.
  3. Write truthTable(f, n) that prints the table of any boolean function with n inputs.
  4. Use it to verify both De Morgan laws and A OR (A AND B) = A.
  5. Explain in a short paragraph why one hex digit is exactly four bits.

References

Related courses