Upgrade to Pro — share decks privately, control downloads, hide ads and more …

All Your Base Are Belong to Us: Counting in Oth...

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on.

All Your Base Are Belong to Us: Counting in Other Bases (Nashville PHP February 2020)

01000001, 2102, 1001, 101, and 41 are all ways to represent the decimal number 65 in bases other than the standard base-10 numeral system we're most familiar with. As programmers, we sometimes encounter these other bases, learn just enough to get by, and move along to the next task. But what if we could think in these other bases? What if we could count in them?

In this talk, we'll learn how to count in other bases, and we'll learn how to convert a number in any base to its base-10 equivalent, without code or a special calculator. We'll explore the most common bases we encounter in our profession (binary, octal, hexadecimal), and we'll play around with some uncommon ones (unary, ternary, duodecimal, sexagesimal, etc.). By the end, all the bases will belong to you!

Avatar for Ben Ramsey

Ben Ramsey PRO

February 12, 2020
Tweet

More Decks by Ben Ramsey

Other Decks in Programming

Transcript

  1. All Your Base Counting in Other Bases Ben Ramsey Nashville

    PHP 11 February 2020 Are belong to us
  2. Base-10 ▪ Otherwise known as “the decimal system” ▪ Greek

    déka; Latin decem ▪ decade, decagon, decameter, December ▪ A numeral system having 10 symbols to represent numbers
  3. 4 6 7 6 ⨉ 103 ⨉ 102 ⨉ 101

    ⨉ 100 ( ) ( ) ( ) ( ) + + +
  4. 4 6 7 6 ⨉ 103 ⨉ 102 ⨉ 101

    ⨉ 100 ( ) ( ) ( ) ( ) + + + 4000 600 70 6
  5. 4 6 7 6 ⨉ 103 ⨉ 102 ⨉ 101

    ⨉ 100 ( ) ( ) ( ) ( ) + + + 4000 600 70 6 = 4676
  6. 0 1 1 1 ⨉ 23 ⨉ 22 ⨉ 21

    ⨉ 20 ( ) ( ) ( ) ( ) + + + 1 1 0 1 ⨉ 27 ⨉ 26 ⨉ 25 ⨉ 24 ( ) ( ) ( ) ( ) + + + +
  7. 0 1 1 1 ⨉ 23 ⨉ 22 ⨉ 21

    ⨉ 20 ( ) ( ) ( ) ( ) + + + 1 1 0 1 ⨉ 27 ⨉ 26 ⨉ 25 ⨉ 24 ( ) ( ) ( ) ( ) + + + + 0 4 2 1 128 64 0 16 = 215
  8. Base-16 ▪ Hexadecimal ▪ A numeral system having 16 symbols

    to represent numbers ▪ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and commonly A, B, C, D, E, and F for numbers 10-15
  9. F A B 1 ⨉ 163 ⨉ 162 ⨉ 161

    ⨉ 160 ( ) ( ) ( ) ( ) + + +
  10. F A B 1 ⨉ 163 ⨉ 162 ⨉ 161

    ⨉ 160 ( ) ( ) ( ) ( ) + + + 61440 2560 176 1
  11. F A B 1 ⨉ 163 ⨉ 162 ⨉ 161

    ⨉ 160 ( ) ( ) ( ) ( ) + + + 61440 2560 176 1 = 64177