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

Bytes

AP.CSP:
DAT‑1 (EU)
,
DAT‑1.A (LO)
,
DAT‑1.A.4 (EK)
,
DAT‑1.A.6 (EK)
A bit is the smallest piece of information in a computer, a single value storing either start text, 0, end text or start text, 1, end text.
A byte is a unit of digital information that consists of 8 of those bits.
Here's a single byte of information:
start text, 11110110, end text
Here are three more bytes of information:
start text, 0, end text, start text, 0, end text, start text, 0, end text, start text, 0, end text, start text, 1010, end text, start text, 0, end text, start text, 101010, end text, start text, 0, end text, start text, 11011011, end text

From bits to bytes

Conversion between bits and bytes is a simple calculation: divide by 8 to convert from bits to bytes or multiply by 8 to convert from bytes to bits. Try it yourself!
Check your understanding
How many bytes long is this binary sequence?
start text, 101110, end text, start text, 01, end text, start text, 11011011, end text, start text, 011010, end text, start text, 01, end text, start text, 0, end text, start text, 0110101, end text, start text, 01111111, end text
  • Your answer should be
  • an integer, like 6
  • a simplified proper fraction, like 3, slash, 5
  • a simplified improper fraction, like 7, slash, 4
  • a mixed number, like 1, space, 3, slash, 4
  • an exact decimal, like 0, point, 75
  • a multiple of pi, like 12, space, start text, p, i, end text or 2, slash, 3, space, start text, p, i, end text

Check your understanding
How many bits are in 8 bytes of information?
  • Your answer should be
  • an integer, like 6
  • a simplified proper fraction, like 3, slash, 5
  • a simplified improper fraction, like 7, slash, 4
  • a mixed number, like 1, space, 3, slash, 4
  • an exact decimal, like 0, point, 75
  • a multiple of pi, like 12, space, start text, p, i, end text or 2, slash, 3, space, start text, p, i, end text

Why bytes?

What is so special about 8 bits that it deserves its own name?
Computers do process all data as bits, but they prefer to process bits in byte-sized groupings. Or to put it another way: a byte is how much a computer likes to "bite" at once.
A computer with a thought bubble with three bytes inside
The byte is also the smallest addressable unit of memory in most modern computers. A computer with byte-addressable memory can not store an individual piece of data that is smaller than a byte.
Memory
AddressData
111110000
200001010
300100110
411000001

What's in a byte?

A byte represents different types of information depending on the context. It might represent a number, a letter, or a program instruction. It might even represent part of an audio recording or a pixel in an image.
We'll explore how computers can use bits and bytes to represent all types of information in this unit.

🙋🏽🙋🏻‍♀️🙋🏿‍♂️Do you have any questions about this topic? We'd love to answer— just ask in the questions area below!

Want to join the conversation?

  • orange juice squid orange style avatar for user Proud
    What if we have a number of bits that are non-divisible by 8? Is that possible?
    (14 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Judepius Ugwuanyi
    "At , what does the concept of byte-addressable imply? A computer should be able to store an individual piece of information, being made of wires?"
    (5 votes)
    Default Khan Academy avatar avatar for user
    • aqualine ultimate style avatar for user Martin
      A byte is a grouping of eight bits. Byte-addressable means that the computer stores data in bytes instead of single bits for example.

      Wires are used for transporting information, computers generally don't use them as a storage device.
      (6 votes)
  • blobby green style avatar for user ralvarez5g
    How do quantum computers work with bits and bytes?
    (4 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user mbanks
    if bits were a thing you can hold what would it look like?
    (1 vote)
    Default Khan Academy avatar avatar for user
    • orange juice squid orange style avatar for user Evan
      We sort of already have that. Take a coin for example, it could either have heads facing up, or tails. So it has two possible states, which is what a bit is. However, a coin stores a bit, rather than actually being a bit. I don't exactly know what bits themself would look like, since they're really just an idea, rather than an actual object.
      (10 votes)
  • starky tree style avatar for user Goku101
    Why bytes?Like why is it 8 and not like like 10 wouldn't that make it easier.
    (1 vote)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user TEDfromTEDtalks
    How would a computer store a piece of information that only requires a bit like if a lightbulb is on or off in byte form?
    (2 votes)
    Default Khan Academy avatar avatar for user
    • leaf green style avatar for user Shane McGookey
      The type of information you are inquiring about is represented by a data type known as a Boolean. A Boolean data type is stored in memory as either a 0 (an equivalent to the lightbulb being in the off state) or 1 (an equivalent to the lightbulb being in the on state).

      Using C++ as a reference, Boolean values are stored as 8-bit (1-byte) values so that they are still addressable. Memory is byte-addressable, so referencing a single bit becomes prohibitive. You can still represent one Boolean per bit, but that would require extra work on the part of the developer as they must now understand and work with bit manipulation.
      (5 votes)
  • duskpin ultimate style avatar for user Isabel
    So if I'm understanding it correctly, a byte doesn't necessarily represent a number using 8 digits - for example the byte 10110110 can mean that:
    First process = 1 = On
    Second process = 0 = Off
    Third = 1 = On
    Fourth = 1 = On
    Fifth = 0 = Off
    Etc...

    Is this correct? Or if a byte is representing separate processes it has to be 00000001 for the first process, 00000000 for the second, etc
    (3 votes)
    Default Khan Academy avatar avatar for user
    • leaf green style avatar for user Shane McGookey
      A byte can represent a number using 8 binary digits; 10110110 would be equivalent to the base-10 number 182 (if we are not considering two's complement representation) or -74 (if we are considering two's complement representation).

      However, a byte (or a multitude of bytes) can represent different types of information depending on the context (as mentioned in the article). A multitude of bytes can represent an image, a text file, a video file, etc.

      Using the byte to represent whether a process is "On" or "Off" in process counts of 8 is not a conventional use that I have come across. However, if you decided to formulate your own unique problem such that a byte represents processes which are on and off then it could be used in that manner (it makes for an intriguing thought experiment). One of the amazing properties of binary representation is how many different types of information can be represented by simple 0s and 1s.

      Do note, though, that on the machine itself processes have process IDs (PIDs) and their metadata is managed by the operating system. Bytes will not be used to represent whether or not processes on a computer are running by flipping bits of the byte to 0 or 1, there are different mechanisms at play.
      (3 votes)
  • duskpin ultimate style avatar for user Hazel
    how do you tell the difference between a 0 and a 1
    (3 votes)
    Default Khan Academy avatar avatar for user
  • blobby purple style avatar for user Reese Bommer
    are there any patterns that one can pic up on in binary.
    (2 votes)
    Default Khan Academy avatar avatar for user
    • starky ultimate style avatar for user aayushchakro
      The evolution of bits goes like this;

      Bits -> Bytes -> Kilobyte -> Megabyte -> Gigabyte -> Terabyte -> Petabyte -> Exabyte

      Starting from bytes, the value is multiplied by 1000 + 24. For example, a thousand and twenty-four kilobytes (1,024 KB) would be a megabyte, and a thousand and twenty=four terabytes would be a petabyte.

      It is sort of a pattern, but if you mean something else, please tell me.
      (3 votes)
  • primosaur tree style avatar for user oscar.sandoval
    why count by 8?
    (2 votes)
    Default Khan Academy avatar avatar for user
    • starky ultimate style avatar for user KLaudano
      Computers started out with 5 bits, but this didn't leave enough options for all the characters we needed to use. So, it grew to 6 and then 7 bits. 7 bits is enough to represent all the characters we can type on a keyboard, but 8 is a power of 2 which made things easier since we were working with binary numbers. So, bytes are now 8 bits.
      (2 votes)