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.

Bits and bytes

# 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!
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

How many bits are in 8 bytes of information?

### 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
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.

## Want to join the conversation?

• What if we have a number of bits that are non-divisible by 8? Is that possible?
• You can always add zeroes to create 8 bit chunks.
• "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?"
• 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.
• How do quantum computers work with bits and bytes?
• if bits were a thing you can hold what would it look like?
(1 vote)
• 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.
• Why bytes?Like why is it 8 and not like like 10 wouldn't that make it easier.
(1 vote)
• In our base 10 system, 10 is a place value represented by 10^1. In binary, however, it's in base 2, so 8 is a place value represented by 2^3.

It's 8, because 8 is close to our friend 10.
• 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?
• 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.
• 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
• 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.
• how do you tell the difference between a 0 and a 1
• You have protocols to define the timing and so on (when does the message start, end).
And then you use different voltages ("high" and "low") to differentiate between 1 and 0.
• are there any patterns that one can pic up on in binary.