If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Binary & data

AP.CSP:
DAT‑1 (EU)
,
DAT‑1.A (LO)
,
DAT‑1.A.2 (EK)
,
DAT‑1.A.3 (EK)
,
DAT‑1.A.6 (EK)
Adafruit founder Limor Fried and program manager Federico Gomez Suarez explain how computers represent numbers, text, images, and sound using tiny electric signals.

Want to join the conversation?

  • female robot ada style avatar for user Katey Gordon
    Is Binary 0 and 1 in Computers like the DNA for Humans except computers use Binary to function the data and information?
    (37 votes)
    Default Khan Academy avatar avatar for user
    • leaf green style avatar for user J Homann
      Binary is more like the smallest building blocks of information (just a 1 or 0). Its how they are strung together that gives the computer instructions and may be closer to DNA since DNA gives our bodies instructions. Binary by it self seems to be closer to atoms (Building blocks).
      Algorithms may also be compared to DNA since they are instructions that tells the computer what to do with the input in order to give output. Really there is no perfect comparison, life and nature are still much much more sophisticated and complicated than even the most advanced computer...so far ;-)
      (33 votes)
  • duskpin tree style avatar for user Nicholas
    255 is the maximum rgb vslue in JavaScript. Why is that?
    (16 votes)
    Default Khan Academy avatar avatar for user
    • leafers ultimate style avatar for user Ilenia
      with three numbers (rrr, ggg, bbb) you can describe 16 777 216, isn't it enough?
      Anyway, human eye can distinguish about 10 millions colors (10 000 000), so being able to use more numbers to describe colors would be a wasteful use of memory.
      Using one less wire would mean having 127 as the max number, and so having 2 097 152 colors, which is not enough
      (44 votes)
  • orange juice squid orange style avatar for user Granttwin
    Is it possible instead of making a computer with switches being either 'on' or 'off', can you make a 'three-way switch' that has 3 different settings like 0, 1, and 2?
    Even better, can computers use hexadecimal instead of binary? Wouldn't it be much more efficient to store information like that?
    (12 votes)
    Default Khan Academy avatar avatar for user
    • duskpin tree style avatar for user Nicholas
      Computers process the binary data via electrical pulses. To represent a 0, we have no pulse, and a 1, we a pulse. If we wanted to have more numbers added, we would use different magnitudes of pulses. However, the transistors are so good they can't quite detect magnitudes of pulses that well, but really can only detect the presence of one. To make it easier to detect the magnitudes, we could have the voltage be higher. But, if the voltage is higher, so is the energy consumption of the computer. For this reason, computers just stick to the simplest number system they can, binary.
      (42 votes)
  • blobby green style avatar for user ulubis98
    if text and photo and video converts to binary, that means everything become binary, so how computer know which is text and which are photo ?
    (11 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Imran Rather
    From of this lecture(i.e. Text in Binary), we learned that we can assign a number to each letter (The ASCII and Unicode System).
    Now one question is troubling me a lot, In ASCII letter 'A' is represented by Decimal 65 and in Binary it will be 01000001 and this binary 65 (01000001) will be stored as a letter 'A' in computers memory, to be outputted by the monitor.

    But at the same time the same binary (01000001) means a numeric 65.

    How does CPU know when to represent (01000001) as letter 'A' and when the number 65?

    Please make it clear to me and I shall be very much thankful to you.
    (6 votes)
    Default Khan Academy avatar avatar for user
    • male robot hal style avatar for user Cameron
      Those bits can be letters, colors, numbers, pictures, or just about anything else you can think of. It is our choice on how we interpret the data.

      Often, for data files, we put some special string of bytes at the beginning of the file (a header), and also we add a file name extension e.g. .pdf, .jpg, etc. to give programs a clue on how we want them to interpret the data. However, those programs can choose to interpet that data in any way that they want e.g. you could try to display a text file as a picture (it would probably just look like a bunch of random pixels)
      (10 votes)
  • blobby green style avatar for user Vikram Bammidi
    After input is given to computer , it will store in the form of 0's and 1'S . Before displaying output how the computer knows that particular combination of binary digits related to image or text or video?
    (3 votes)
    Default Khan Academy avatar avatar for user
    • male robot hal style avatar for user Cameron
      Often, files containing binary data will have a "file signature" at the front of the file which gives a clue to what the data is. For example for a PNG image file the first 8 bytes are:
      The first eight bytes of a PNG file always contain the following values:
      (decimal) 137 80 78 71 13 10 26 10
      (hexadecimal) 89 50 4e 47 0d 0a 1a 0a
      (ASCII C notation) \211 P N G \r \n \032 \n

      So an image program could look at a file with this signature, and know that is probably a PNG file. However, you could still open that file up in a text editor and display it as text (most of it, other than the file signature would look probably look like random text), or you could try to play it as an audio file (it would probably sound like static).

      Some programs, will just give you an error message, if it looks for a file signature and doesn't find anything that it recognizes.
      (16 votes)
  • spunky sam blue style avatar for user Zach
    How do they use quantum computers that give off both a 1 and a 0 at the same time?
    (9 votes)
    Default Khan Academy avatar avatar for user
  • female robot ada style avatar for user Amelia
    Does every coding language use and/or is made up of binary?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • duskpin tree style avatar for user zebby @tim
    how are pictures on the internet in color if everything is a 1 or a 0? shouldn't everything be in black and white?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • primosaur seed style avatar for user Mrutyunjaya sahoo
    What is virus ?
    (4 votes)
    Default Khan Academy avatar avatar for user

Video transcript

(upbeat music) - Hi, my name is Limor Fried, and I'm an engineer here at Adafruit Industries, and this is where I do engineering and design, and I design circuits for fashion and music and technology. - My name is Federico Gomez Suarez, and I'm a software developer with Microsoft Hack for Good, and I look into using technology to help solve some of the big social problems of our times. (upbeat music) - You may have heard that computers work on ones and zeroes, or you may have seen scary-looking visuals like this. But almost nobody today actually deals directly with these ones and zeroes, but ones and zeroes do play a big role in how computers work on the inside. - Inside a computer are electric wires and circuits and carry all the information in a computer. How do you store or represent information using electricity? - Well, if you have a single wire with electricity flowing through it, the signal can either be on or off. That's not a lot of choices, but it's a really important start. With one wire, we can represent a "yes" or a "no," true or false, a one or a zero, or anything else with only two options. This on/off state of a single wire is called a bit, and it's the smallest piece of information the computer can store. If you use more wires, you get more bits. More ones and zeroes with more bits, you can represent more complex information. But to understand that, we need to learn about something called the binary number system. (calm music) - In the decimal number system, we have 10 digits from zero to nine, and that's how we've all learned to count. In the binary number system, we only have two digits, zero and one. With these two digits, we can count up to any number. Here's how this works. In the decimal number system we're all used to, each position in a number has a different value. There's the one position, the 10 position, the 100 position, and so on. For example, a nine in the 100 position is a 900. In binary, each position also carries a value, but instead of multiplying by 10 each time, you multiply by two. So there's the one's position, the two's position, four's position, the eight's position, and so on. For example, the number nine in binary is 1001. To calculate the value, we add one times eight, plus zero times four, plus zero times two, plus one times one. Almost nobody does this math because computer do it for us. What's important is that any number can be represented with only ones and zeroes, or by a bunch of wires that are on or off. The more wires you use, the larger the numbers you can store. With eight wires, you can store numbers between zero and 255. That's eight ones. With just 32 wires, you can store all the way from zero to over four billion. Using the binary number system, you can represent any number you like. But what about other types of information, like text, images, or sound? It turns out that all these things can also be represented with numbers. (upbeat music) Think of all the letters in the alphabet. You could assign a number to each letter. "A" could be "1," "B" could be "2," and so on. You can then represent any word or paragraph as a sequence of numbers, and as we saw, these numbers can be stored as on or off electrical signals. Every word you see on every webpage or your phone is represented using a system like this. (upbeat music) Now, let's consider photos, videos, and all the graphics you see on a screen. All of these images are made out of teeny dots called pixels, and each pixel has color. Each of the colors can be represented with numbers. When you consider that a typical image has millions of these pixels, and a typical video shows 30 images per second, now, we're taking about a lot of data here. (upbeat music) - Every sound is basically a series of vibrations in the ear. Vibrations can be represented graphically as a waveform. Any point on this waveform can be represented by a number. And this way, any sound can be broken down into a series of numbers. If you want higher-quality sound, you will pick 32-bit audio over 8-bit audio. More bits means a higher range of numbers. - When you use a computer to write code or make your own app, you're not dealing directly with these ones and zeroes, but you will be dealing with images, or sound, or video. So, if you want to understand how computers work on the inside, it all comes down to these simple ones and zeroes and the electrical signals in the circuits behind them. They are the backbone of how all computers input, store, process, and output information. (upbeat music)