engineering with ai & stuffwith Mungai Bedan

Lesson 01 · Number systems

Same number.
Four outfits.

Binary, octal, decimal & hex — the way computers count, minus the headache.

Drops in

Sat 10 Oct · 7 PM EAT

Dropping on TikTok & WasaaChat · bring a notebook

Try it · type in any card

All four are the same number. By Saturday night you'll read them all.

There are 10 kinds of people: those who get binary, and those who don't. Be the first kind.

Notes · coming soon

The written notes land here soon.

Worked examples, practice questions with answers, and everything from the video, written down. Lesson 01 drops Sat 10 Oct · 7 PM EAT on TikTok & WasaaChat.

Building with AI: how the cards work

The four cards at the top are about 60 lines of React. None of those lines do the conversion maths. JavaScript already reads every outfit, as long as you tell it which one with a prefix: 0b for binary, 0o for octal, 0x for hex, and none for decimal.

BigInt("0b101010")  // 42n
BigInt("0o52")      // 42n
BigInt("42")        // 42n
BigInt("0x2A")      // 42n

Going the other way, toString takes the base you want:

const n = 42n;
n.toString(2);   // "101010"
n.toString(8);   // "52"
n.toString(16);  // "2a"

That's the whole converter. Each card knows its prefix. Only the card you type in is stored, and the other three are worked out from it, so the four can never disagree.

Why BigInt and not a normal number?

A normal JavaScript number is only exact up to 2532^{53}. Past that, it quietly rounds:

Number("0b" + "1".repeat(64))
// 18446744073709552000 rounded!
BigInt("0b" + "1".repeat(64))
// 18446744073709551615n exact

Sixty-four 1s in binary is 264−12^{64} - 1, which is 18,446,744,073,709,551,615. Paste 64 ones into the binary card and check.

Build your own with an AI assistant

Give it a prompt like this:

Build a React component with four text inputs: binary, octal, decimal and hex. Typing in any one updates the other three. Use BigInt so big numbers stay exact. If someone types a digit that doesn't belong in that base, show a friendly error instead of a wrong answer.

Then test what it gives you. Don't trust it until all three pass:

  1. Type 255 in decimal. You should see 11111111, 377 and FF.
  2. Type 2 in binary. You should get an error, not a number.
  3. Paste 64 ones into binary. Decimal should read 18446744073709551615.

What does BigInt("0x1F") give?

Show answer

31n, because hex 1F is 1×16+15=311 \times 16 + 15 = 31.