< Return to Video

How exactly does binary code work? - José Américo N L F Freitas

  • 0:07 - 0:11
    Imagine trying to use words
    to describe every scene in a film,
  • 0:11 - 0:13
    every note in your favorite song,
  • 0:13 - 0:16
    or every street in your town.
  • 0:16 - 0:21
    Now imagine trying to do it using
    only the numbers 1 and 0.
  • 0:21 - 0:24
    Every time you use the Internet
    to watch a movie,
  • 0:24 - 0:25
    listen to music,
  • 0:25 - 0:26
    or check directions,
  • 0:26 - 0:29
    that’s exactly what your device is doing,
  • 0:29 - 0:32
    using the language of binary code.
  • 0:32 - 0:37
    Computers use binary because
    it's a reliable way of storing data.
  • 0:37 - 0:41
    For example, a computer's main
    memory is made of transistors
  • 0:41 - 0:44
    that switch between either high
    or low voltage levels,
  • 0:44 - 0:48
    such as 5 volts and 0 volts.
  • 0:48 - 0:52
    Voltages sometimes oscillate,
    but since there are only two options,
  • 0:52 - 0:56
    a value of 1 volt
    would still be read as "low."
  • 0:56 - 0:58
    That reading is done by
    the computer’s processor,
  • 0:58 - 1:03
    which uses the transistors’ states
    to control other computer devices
  • 1:03 - 1:05
    according to software instructions.
  • 1:05 - 1:08
    The genius of this system
    is that a given binary sequence
  • 1:08 - 1:12
    doesn't have a pre-determined meaning
    on its own.
  • 1:12 - 1:15
    Instead, each type of data
    is encoded in binary
  • 1:15 - 1:18
    according to a separate
    set of rules.
  • 1:18 - 1:19
    Let’s take numbers.
  • 1:19 - 1:21
    In normal decimal notation,
  • 1:21 - 1:26
    each digit is multiplied by 10 raised
    to the value of its position,
  • 1:26 - 1:28
    starting from zero on the right.
  • 1:28 - 1:35
    So 84 in decimal form is 4x10⁰ + 8x10¹.
  • 1:35 - 1:38
    Binary number notation works similarly,
  • 1:38 - 1:42
    but with each position
    based on 2 raised to some power.
  • 1:42 - 1:46
    So 84 would be written as follows:
  • 1:46 - 1:50
    Meanwhile, letters are interpreted
    based on standard rules like UTF-8,
  • 1:50 - 1:55
    which assigns each character to a specific
    group of 8-digit binary strings.
  • 1:55 - 2:02
    In this case, 01010100 corresponds
    to the letter T.
  • 2:02 - 2:06
    So, how can you know whether
    a given instance of this sequence
  • 2:06 - 2:09
    is supposed to mean T or 84?
  • 2:09 - 2:12
    Well, you can’t from seeing
    the string alone
  • 2:12 - 2:16
    – just as you can’t tell what the sound
    "da" means from hearing it in isolation.
  • 2:16 - 2:21
    You need context to tell whether you're
    hearing Russian, Spanish, or English.
  • 2:21 - 2:23
    And you need similar context
  • 2:23 - 2:27
    to tell whether you’re looking
    at binary numbers or binary text.
  • 2:27 - 2:31
    Binary code is also used for
    far more complex types of data.
  • 2:31 - 2:33
    Each frame of this video, for instance,
  • 2:33 - 2:36
    is made of hundreds
    of thousands of pixels.
  • 2:36 - 2:38
    In color images,
  • 2:38 - 2:41
    every pixel is represented
    by three binary sequences
  • 2:41 - 2:44
    that correspond to the primary colors.
  • 2:44 - 2:45
    Each sequence encodes a number
  • 2:45 - 2:49
    that determines
    the intensity of that particular color.
  • 2:49 - 2:53
    Then, a video driver program transmits
    this information
  • 2:53 - 2:55
    to the millions of liquid crystals
    in your screen
  • 2:55 - 2:58
    to make all the different hues
    you see now.
  • 2:58 - 3:01
    The sound in this video
    is also stored in binary,
  • 3:01 - 3:05
    with the help of a technique
    called pulse code modulation.
  • 3:05 - 3:07
    Continuous sound waves are digitized
  • 3:07 - 3:12
    by taking "snapshots" of their
    amplitudes every few milliseconds.
  • 3:12 - 3:15
    These are recorded as numbers
    in the form of binary strings,
  • 3:15 - 3:19
    with as many as 44,000
    for every second of sound.
  • 3:19 - 3:22
    When they’re read by
    your computer’s audio software,
  • 3:22 - 3:26
    the numbers determine how quickly
    the coils in your speakers should vibrate
  • 3:26 - 3:29
    to create sounds of different frequencies.
  • 3:29 - 3:33
    All of this requires billions
    and billions of bits.
  • 3:33 - 3:37
    But that amount can be reduced
    through clever compression formats.
  • 3:37 - 3:41
    For example, if a picture has 30 adjacent
    pixels of green space,
  • 3:41 - 3:46
    they can be recorded as "30 green" instead
    of coding each pixel separately -
  • 3:46 - 3:49
    a process known as run-length encoding.
  • 3:49 - 3:54
    These compressed formats are themselves
    written in binary code.
  • 3:54 - 3:57
    So is binary the end-all-be-all
    of computing?
  • 3:57 - 3:59
    Not necessarily.
  • 3:59 - 4:01
    There’s been research
    into ternary computers,
  • 4:01 - 4:03
    with circuits in three possible states,
  • 4:03 - 4:05
    and even quantum computers,
  • 4:05 - 4:09
    whose circuits can be
    in multiple states simultaneously.
  • 4:09 - 4:11
    But so far, none of these has provided
  • 4:11 - 4:15
    as much physical stability
    for data storage and transmission.
  • 4:15 - 4:17
    So for now, everything you see,
  • 4:17 - 4:18
    hear,
  • 4:18 - 4:19
    and read through your screen
  • 4:19 - 4:23
    comes to you as the result
    of a simple "true" or "false" choice,
  • 4:23 - 4:25
    made billions of times over.
Title:
How exactly does binary code work? - José Américo N L F Freitas
Speaker:
José Américo N L F Freitas
Description:

View full lesson: https://ed.ted.com/lessons/how-exactly-does-binary-code-work-jose-americo-n-l-f-freitas

Imagine trying to use words to describe every scene in a film, every note in a song, or every street in your town. Now imagine trying to do it using only the numbers 1 and 0. Every time you use the Internet to watch a movie, listen to music, or check directions, that’s exactly what your device is doing, using the language of binary code. José Américo N L F de Freitas explains how binary works.

Lesson by José Américo N L F de Freitas, animation by Qa'ed Mai.

more » « less
Video Language:
English
Team:
closed TED
Project:
TED-Ed
Duration:
04:41

English subtitles

Revisions Compare revisions