Representing and manipulating data in computers
Representing and manipulating data in computers

Start this free course now. Just create an account and sign in. Enrol and complete the course for a free statement of participation or digital badge if available.

Free course

Representing and manipulating data in computers

6 Manipulating data in computers: introduction

Sections 1 to 5 of this course have shown that in a computer all types of data are represented by binary codes, and that programmers must make sure that the programs they write treat this data appropriately in any particular application: as text if it is intended to be text, as a binary fraction if it is intended to be a binary fraction, and so on.

Programmers must also ensure that the programs manipulate the binary codes in an appropriate way for the particular application. But what sorts of manipulation are possible inside a computer?

Perhaps surprisingly, a great deal of data manipulation in a computer is simply moving data around without changing it at all.

Not so surprisingly, a fair amount of the data manipulation takes the form of arithmetic: addition, subtraction, multiplication and division. For example, some of the lossy compression techniques I mentioned in Sections 3.3 and 4.3 require a great deal of arithmetic. I'll talk more about arithmetic involving binary numbers in Section 7.

Another common manipulation is comparing data (with a view to taking an action that depends on the result of the comparison). This is usually referred to as testing. Think for example about a spell-check program that is checking whether a word in the email you have just typed is in its dictionary. The letters in your word and the letters in the word in the dictionary will all be in ASCII format. Pairs of ASCII codes can then be compared systematically, and if the codes in each pair are identical then your word is identical to the word in the dictionary and the spell checker can move on to the next word in your email. If all the codes are not identical then either the computer has yet to find the word you are using, or possibly you have a made spelling mistake, or the word is not in its dictionary. Either way, what the computer does next depends on the outcome of the comparison test.

The fourth sort of data manipulation, not so common but still used, is logic operations on the data. I'll explain what I mean by logic operations in Section 8, and give an example of how such manipulations could be used.

So there are four basic types of data manipulation carried out in computers:

  • moving data around unchanged;

  • carrying out arithmetic operations on data;

  • testing data;

  • carrying out logic operations on data.

In this course I will focus on arithmetic operations (Section 7) and logic operations (Section 8).

In computers, arithmetic and logic operations are carried out by a crucial component in the processor called an arithmetic-logic unit (ALU). So when you look at arithmetic and logic operations in Sections 7 and 8 you will be looking at the operations carried out by the processor's ALU.

For simplicity, I shall use 8-bit words throughout Sections 7 and 8, but the principles are equally applicable to binary data words of other lengths, and ALUs may indeed be designed to act on 16-, 32- or even 64-bit words.


Take your learning further

Making the decision to study can be a big step, which is why you'll want a trusted University. The Open University has 50 years’ experience delivering flexible learning and 170,000 students are studying with us right now. Take a look at all Open University courses.

If you are new to University-level study, we offer two introductory routes to our qualifications. You could either choose to start with an Access module, or a module which allows you to count your previous learning towards an Open University qualification. Read our guide on Where to take your learning next for more information.

Not ready for formal University study? Then browse over 1000 free courses on OpenLearn and sign up to our newsletter to hear about new free courses as they are released.

Every year, thousands of students decide to study with The Open University. With over 120 qualifications, we’ve got the right course for you.

Request an Open University prospectus371