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

The Power of 2

The Power of 2

Igor Wiedler

April 12, 2017
Tweet

More Decks by Igor Wiedler

Other Decks in Programming

Transcript

  1. the power of
    2
    @igorwhilefalse

    View Slide

  2. 2n

    View Slide

  3. 2×2×…
    n

    View Slide

  4. 2 4 8

    View Slide

  5. 2 4 8 16 32 64 128 256

    View Slide

  6. 2 4 8 16 32 64 128 256
    512 1024 2048 4096 8192 16384 32768 65536

    View Slide

  7. 2 4 8 16 32 64 128 256
    512 1024 2048 4096 8192 16384 32768 65536
    131K 262K 524K 1M 2M 4M 8M 16M
    33M 67M 134M 268M 536M 1B 2B 4B
    8B 17B 34B 68B 137B 274B 549B 1T
    2T 4T 8T 17T 35T 70T 140T 281T
    562T 1Q 2Q 4Q 9Q 18Q 36Q 72Q
    144Q 288Q 576Q 1Quint 2Quint 4Quint 9Quint 18Quint

    View Slide

  8. 18'446'744'073'709'551'616

    View Slide

  9. 18'446'744'073'709'551'616
    grains of rice

    View Slide

  10. alot by @alliebrosh

    View Slide

  11. 2 4 8 16 32 64 128 256
    512 1024 2048 4096 8192 16384 32768 65536
    131K 262K 524K 1M 2M 4M 8M 16M
    33M 67M 134M 268M 536M 1B 2B 4B
    8B 17B 34B 68B 137B 274B 549B 1T
    2T 4T 8T 17T 35T 70T 140T 281T
    562T 1Q 2Q 4Q
    18Q 36Q 72Q
    144Q 288Q 576Q 1Quint 2Quint 4Quint 9Quint 18Quint

    View Slide

  12. 2 4 8 16 32 64 128 256
    512 1024 2048 4096 8192 16384 32768 65536
    131K 262K 524K 1M 2M 4M 8M 16M
    33M 67M 134M 268M 536M 1B 2B 4B
    17B 34B 68B 137B 274B 549B 1T
    2T 4T 8T 17T 35T 70T 140T 281T
    562T 1Q 2Q 4Q 9Q 18Q 36Q 72Q
    144Q 288Q 576Q 1Quint 2Quint 4Quint 9Quint 18Quint

    View Slide

  13. 2 4 8 16 32 64 128 256
    512 1024 2048 4096 8192 16384 32768 65536
    131K 262K 524K 1M 2M 4M 8M 16M
    33M 67M 134M 268M 536M 1B 2B 4B
    8B 17B 34B 68B 137B 274B 549B 1T
    2T 4T 8T 17T 35T 70T 140T 281T
    562T 1Q 2Q 4Q 9Q 18Q 36Q 72Q
    144Q 288Q 576Q 1Quint 2Quint 4Quint 9Quint 18Quint

    View Slide

  14. 2 4 8 16 32 64 128 256
    512 1024 2048 4096 8192 16384 32768 65536
    131K 262K 524K 1M 2M 4M 8M #cafeee
    33M 67M 134M 268M 536M 1B 2B 4B
    8B 17B 34B 68B 137B 274B 549B 1T
    2T 4T 8T 17T 35T 70T 140T 281T
    562T 1Q 2Q 4Q 9Q 18Q 36Q 72Q
    144Q 288Q 576Q 1Quint 2Quint 4Quint 9Quint 18Quint

    View Slide

  15. 2 4 8 16 32 64 128 256
    512 1024 2048 4096 8192 16384 32768 65536
    131K 262K 524K 1M 2M 4M 8M 16M
    33M 67M 134M 268M 536M 1B 2B 4B
    8B 17B 34B 68B 137B 274B 549B 1T
    2T 4T 8T 17T 35T 70T 140T 281T
    562T 1Q 2Q 4Q 9Q 18Q 36Q 72Q
    144Q 288Q 576Q 1Quint 2Quint 4Quint 9Quint 18Quint

    View Slide

  16. 2 4 8 16 32 64 128 256
    512 1024 2048 4096 8192 16384 32768 65536
    131K 262K 524K 1M 2M 4M 8M 16M
    33M 67M 134M 268M 536M 1B 2B 4B
    8B 17B 34B 68B 137B 274B 549B 1T
    2T 4T 8T 17T 35T 70T 140T 281T
    562T 1Q 2Q 4Q 9Q 18Q 36Q 72Q
    144Q 288Q 576Q 1Quint 2Quint 4Quint 9Quint 18Quint

    View Slide

  17. 2 4 8 16 32 64 128 256
    512 1024 2048 4096 8192 16384 32768 65536
    131K 262K 524K 1M 2M 4M 8M 16M
    33M 67M 134M 268M 536M 1B 2B 4B
    8B 17B 34B 68B 137B 274B 549B 1T
    2T 4T 8T 17T 35T 70T 140T 281T
    562T 1Q 2Q 4Q 9Q 18Q 36Q 72Q
    144Q 288Q 576Q 1Quint 2Quint 4Quint 9Quint 18Quint

    View Slide

  18. 2n

    View Slide

  19. exponential growth
    • population growth
    • infection (zombie apocalypse)
    • economic growth (mod humans)
    • moore's law

    View Slide

  20. crypto
    • one char = { 0 1 2 3 4 5 6 7 8 9 a b c d e f }

    possible values: 161 = 16
    • two chars = {

    00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f

    10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f

    20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f

    ...

    }

    possible values: 162 = 256

    64 bit key: 264 = 1616 = 18Quint

    View Slide

  21. we scaled up
    let's scale down

    View Slide

  22. log2 n

    View Slide

  23. n÷2÷…=1
    y

    View Slide

  24. dress shopping

    View Slide

  25. dress shopping

    View Slide

  26. dress shopping

    View Slide

  27. dress shopping

    View Slide

  28. dress shopping

    View Slide

  29. dress shopping

    View Slide

  30. dress shopping

    View Slide

  31. binary search

    View Slide

  32. database

    View Slide

  33. log2 n

    View Slide

  34. log2 (18'446'744'073'709'551'616)
    = 64

    View Slide

  35. atoms
    • atoms in a human body: 7×1027


    => 7'000'000'000'000'000'000'000'000'000

    => log2 = 92
    • atoms in observable universe: 4×1079


    => 40'000'000'000'000'000'000'000'000'000

    '000'000'000'000'000'000'000'000'000

    '000'000'000'000'000'000'000'000

    => log2 = 264

    View Slide

  36. recap
    • 2n

    grows large fast

    232 = 4B

    264 = 18Quint
    • log2 n

    decreases quickly

    log2 4B = 32

    log2 18Quint = 64
    yay crypto
    and grains of
    rice
    yay databases
    and dresses

    View Slide

  37. thank u
    zine: igor.io/pow
    @igorwhilefalse

    View Slide