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

The sad, strange tale of the boy with only two ...

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers. →

The sad, strange tale of the boy with only two fingers - OR - An introduction to binary for non-robot human people

Most people know that computers are "just a bunch of ones and zeroes," but few understand what that really means. How do ones and zeros become numbers, words, and pictures? This talk starts at the beginning, explaining binary numbers and shows how they are used to describe basic datatypes. We begin to uncover what the statement "just a bunch of ones and zeroes" really means.

Avatar for Mims H. Wright

Mims H. Wright

October 13, 2015

Other Decks in Programming

Transcript

  1. The sad, strange tale of the boy with only two

    fingers: an introduction to binary for non-robot, human people
  2. 1 1 1 1 1 1 1 1
 Byte (8

    bits) Nibble (4 bits) 1 Bit Bits & Bytes
  3. 128 64 32 16 8 4 2 1 1 1

    1 1 1 1 1 1 128+64+32+16+8+4+2+1=255 Value of each Bit in a Byte Powers of 2
  4. 2 3 4 5 6 7 8 9 A B

    1 C D E F 10
  5. 1 0 0 1
 
 
 0 0 1 1


    
 
 1 1 0 1
 Test your might!
  6. 1 0 0 1
 
 
 0 0 1 1


    
 
 1 1 0 1
 Test your might! = 9 = 3 = 13 
 8 4 2 1
 
 8 4 2 1
 
 8 4 2 1
  7. 1001 (9)
 x 1100 (12)
 ——————————- 
 0000 xxx 


    00000 x xxx
 100100 x xxx
 + 1001000 x xxx 
 -—————————————-
 1101100 (108) Arithmetic works the same way.
  8. Memory. TuringMachine. “Turing's greatest contribution to the development of the

    digital computer [was the] idea of controlling the function of a computing machine by storing a program of … numerically, encoded instructions in the machine's memory” http://www.alanturing.net/
  9. How many 1’s and 0’s determine the maximum size of

    the number 8 bits (0 to 255) 16 bits (0 to 64,000ish) 32 bits (0 to 4.3 billionish)
  10. Use 1 bit to allow negatives. This cuts the maximum

    number in half. 8 bits (-127 to 127) 16 bits (-32K to 32K) 32 bits (-2.2B to 2.2B)
  11. A vastly simplified version… that is still pretty confusing 1

    + 1/2 + 1/4 + 1/8 + 1/16… 1 0 1 1… 24 bits determine the base number 7 bits for the exponent 1.2345678 1 bit for the sign 1 0001101 × ×29 - -632.0987136
  12. 0.2 + 0.1 == 0.3; 0.30000000000000004 0.2 + 0.1; //

    Javascript // 8-((((((((( 0.2 + 0.1 == 0.3; // FALSE!
  13. Can be as simple as 3 numbers… • A place

    to look in memory • The number of bits in each item • The number of items An array is a set of multiple values.
  14. 0 0 1 0 0 1 0 1 0 0

    1 0 Data in memory location 0 location 4 location 8 Array of pointers
  15. • 1 million + glyphs • Allows a huge number

    of characters to be represented with as few bits as possible. • Uses a form of data compression. Unicode.
  16. • An array of characters. • A null character (eight

    0s) marks the end of a string. Strings.
  17. 0100 1101 “M” 0110 1001 “i” 0110 1101 “m” 0111

    0011 “s” 0000 0000 “ ”
 
 “Mims ”
  18. Colors are 24 bits (aka 3 bytes or 6 hex

    digits) Colors sometimes have an alpha channel (32 bits) Each color channel has 256 possible brightness levels