Home » Computer Guides » How Does a PC Store Data

how does a computer store data?

Your computer stores data as ones and zeros. You've probably heard that much. But where do these ones and zeros come from? What are they? And how can a computer store ones and zeros anyway?

Questions, questions and only vague fuzzy answers.

In this guide, I'm going to try to demystify how computers actually manage to store your files.

How they can hold your documents, pictures and music in electronic form, ready for when you want them.

athomecomputer.co.uk - how a pc stores data

it's all ones and zeros to me.

Let's talk about those ones and zeros first, because they are crucial to understanding how a PC stores data.

Where exactly do they come from? Once we know how we get the ones and zeros, we can move onto how your computer might actually store them.

I'm going to focus on text, specifically individual letters.

Once we know how letters can be stored on a computer, everything else will just follow on.

A computer is just an over blown calculator.

After all, that's where it's name comes from. To compute, to calculate.

And as we all know, calculators work with numbers.

They don't do letters.

I know that sounds weird, when your reading this on your computer, but it's true.

a computer is just a calculator.

I'm going to be mentioning ones and zeros a great deal in this guide.

Would it be OK with you guys if I referred to them as bits. That's their collective name.

A, B, C, D etc are letters and 1, 2, 3, 4 etc are numbers. The ones and zeros on a computer are bits.

ASCII table.

So since we can't type letters into a computer (a calculator), what we need is a way to convert the letters, into numbers that your computer can use.

To that end, a table was produced. It's called the ASCII (American Standard Code for Information Interchange) table.

Simply put, it assigns each letter of the alphabet a number.

On the ASCII table, the capital letter A is 65 and the capital letter B is 66 and capital C is 67 and so on.

You may have done something similar at school, passing secret messages to each other.

The messages are in code, replacing letters with numbers.

storing decimal as binary.

But this is where we run into a little issue.

Those numbers, 65, 66 and 67 (A, B, C etc) are decimal numbers. That's how we humans count. We count in tens.

Your computer counts in the Binary system. Ones and Zeros. It stores data as ones and zeros (bits).

In Binary, you can have any decimal number that you can think of, there's no limit, but when you write it down, it'll look very different.

So for our computer to be able to store (or save) those letters, we have to convert all the decimal numbers to their binary equivalents.

Here's a selection of letters from the ASCII table.

You can see that every letter is represented by a decimal number, which then gets converted into a binary number. A whole load of ones and zeros.

It's the binary column that your computer uses.

And essentially, that's where the term, or phrase ones and zeros comes from.

So if we were to write the letters A, B and C, what the computer would see is

01000001, 01000010 and 01000011

a selection from the ASCII table.

storing the letter A, 01000001

So now we know where the ones & zeros (the bits) come from.

But how can we save those binary numbers on a computer, how can we store them?

After all, it's easy to write them down with pen and paper, but the computer doesn't have writing materials.

So just how does it do it?

Well to answer that, let me stretch your imagination a little.

We know that the letter A is  represented by the binary number 01000001 to the computer.

So we don't have to save the letter A as such, what we need to do is to save it's binary code 01000001.

Now looking at that number, there are 8 digits. 8 ones & zeros (8 bits).

Suppose we had 8 light bulbs.

If we said that a light bulb that's turned off is a zero, and a light bulb that's on is a one.

Capital letter a.

You can see that we could easily store the letter A electronically. Simply by turning the light bulbs on or off.

And if we can store the letter A, we could also save any other letter of the alphabet.

storing data with magnets.

You might remember bar magnets from school.

But the important thing for us to know is that they have a north pole at one end and a south pole at the other.

The ones at my  school were painted red for north and blue for south.

So we're looking at the top of the magnet. Only the very top.

Now just like the with the light bulbs earlier, if we said that a south pole (blue end) represents a zero and a north pole ( red end) is a one.

Then by flipping the magnets over into the correct order, we can save our letter A magnetically.

the letter a saved magnetically.

Looking down onto the top of the magnets, we'd see something like this.

From left to right we've got -

A South pole representing a zero,
a North pole representing a one,
then five South poles representing five zeros,
and finally a North pole representing a one.

01000001 = 65 in decimal = the capital letter A

the magnets from above.

free computer course.

Looking to improve your skills on your computer. Take a look at our computer course

Advertisement

storing data on a hard drive/disk.

All the data, all the files, on your computer are stored onto a device called the hard drive, or sometimes called hard disk.

There are different types of hard drive, but I'll focus here on the traditional "spinning" drives because they are still the most prevalent drives.

The hard drive is a little like an old record player.

It's got a disc that spins and an arm that runs over the disc.

But that's where the similarity ends.

The disc on a hard drive doesn't have grooves, instead it's a smooth surface covered with a special magnetic coating.

And the arm doesn't have a needle, but special sensors that can detect the polarity (North or South) of magnets.

a typical hard drive in action.

The sensors, which are called Read/Write heads have two functions.

Firstly, they "read" or detect, whether they're passing over a north pole or south pole, a one or a zero.

And secondly, they can change the polarity from north to south and vice versa.

sNSSSSSN, the letter A.

Obviously the disk of the hard drive doesn't have a bundle of bar magnets stood on end and glued to it's surface. But the principle is the same.

The arm on the hard drive is looking down onto tiny magnetic "points" on the disc.

Millions, billions of them. And each one could be a North pole or a South pole.

So each magnetic point represents a single bit, a single one or zero.

And the hard drive can tell the difference between the North Pole and South poles of the magnetic points.

But better than that, it can zap them, to change their polarity from North to South and vice versa.

So when it's reading the data, it's simply detecting whether it's passing over North or South poles, ones or zeros.

When it's writing data to the disk (storing data), it zaps each magnetic point to be which pole it needs it to be.

If we take a typical hard drive as being around 500 Gigabytes.

Then there would be 4,000,000,000,000 individual points of magnetism.

Each point is a bit, or a one or zero. A North pole or a South pole.

If you'd like to know more about how bits and Bytes work click here What are Kilobytes, Megabytes, Gigabytes and All That.

there's a lot of bits in a Gigabyte.

The ASCII table has a numerical code for every key on your keyboard. Letters, numbers and symbols.

All of which are converted to their binary equivalents, which means they can be stored as bits (ones and zeros).

And as we've seen, we can save these bits magnetically on our hard drives as North poles or South poles.

Which in turn, means we can save the entire works of Shakespeare, the Encyclopaedia Britannica and Dr Zhivago on our computer. As well as my scribblings.

For a complete explanation of the ASCII table, here is the Wiki page https://en.wikipedia.org/wiki/ASCII

Advertisement

storing picture files.

We've seen how all the letters of the alphabet need to be converted into binary numbers in order to be stored on a PC.

That's because binary numbers, ones and zeros, align perfectly with the North pole and South pole of magnets. The two are interchangeable.

A North pole can represent a one and a South pole can represent a zero. It's perfect.

Well everything on your PC has to saved this way. Because on a hard drive, we've only got a North pole and a South pole, a one or a zero. We don't have anything else.

So how can we store pictures on a computer?

Paint By Numbers.

Paint by numbers has been around for ever.

And as you'll all be aware, the colours are represented by numbers.

Sure, they're decimal numbers, but we can convert those to binary numbers easily enough.

And once we've got them converted to binary ones and zeros, we can save them as North or South poles on a hard drive..

painting by numbers.

On the colour palette above, we've got 14 colours, numbered 1 to 14.

Your computer probably uses, what's called 32 bit colour. Which means it has a colour palette of around 16.7 million colours.

Each and every one of those 16 million + colours has it's own, unique, binary number, which means it can be saved as ones and zeros, or North poles and South poles.

And although a PC's colour palette is unimaginably huge, it works exactly the same as our paint by numbers palette.

Digital pictures are divided into a kind of grid.

The squares of the grid are called pixels.

Unlike my picture opposite, pixels are tiny.

A 1 Megapixel photo has got 1 million pixels, or 1 million squares.

Way too small for us to see them individually.

digital images are made up of pixels.

When a digital picture is created, each pixel's position and colour is recorded.

The pixel's position can easily be recorded as a number, a little like a map reference.

And it's colour is chosen from the nearest match from the computer or camera's colour palette.

Then by combining these two numbers, hey presto, we've converted 1 pixel into a number.

Into a binary number that your computer can store.

pixels.

And if we we're looking at a 1 Megapixel photo, we'd have just another 999,999 pixels to go.

When all the pixels are re-assembled in the correct order and with the correct colour, we see a picture.

how does a PC know the difference between pitures and text?

If everything on the computer is just ones and zeros, North poles and South poles, how does your PC know the difference between picture files and text files or anything else?

That's a very good question, with a surprisingly simple answer.

When you save a file, whatever it is, it's just a bunch of ones and zeros. But, the computer adds extra information to the file.

It makes a note as to what the file is supposed to be, whether it's a text file, a picture file, a music file etc.

You see, for each file type, the bits, the ones and zeros, must be laid out in a particular order. A particular pattern, if you like.

Which is why we need different programs to open different file types.

The way in which the bits are ordered, or laid out, is called the file format.

You can find out more about file formats here What are File Formats

Advertisement

kilobytes & megabytes.

Just what are Kilobytes, Megabytes and Gigabytes.

what's inside a PC?

Put names to the main components of a computer.

make your own CD's

Make your own compilation music CD's that'll play in your stereo.

free computer course.

Looking to improve your skills on your computer. Take a look at our computer course