Data types: numbers, words and pictures — Computing, 7–10
Computers treat different kinds of information in different ways. Computing, 7–10 years.
Different information needs different treatment
A computer can handle a number, a word, a picture or a yes/no answer, but they are not the same kind of thing. It needs to know the kind so it can add numbers, join words, show pictures or make a choice correctly. This kind is called a data type.
Why types matter
The problem appears when a computer receives symbols without knowing what they mean. The characters 2 and 3 can be numbers to add, or letters in a code such as 23. People use context naturally, but a computer needs a clear label or it may calculate, compare or display the information in the wrong way.
A tiny example
Imagine a quiz asking your age and your name. You enter 8 for age and Mia for name. The program treats 8 as a number, so it can calculate 8 + 1 = 9 for next year; it treats Mia as text, so it can display Hello, Mia. If it treated Mia as a number, that step would make no sense.
A number written as text
A common surprise is that 2 and 20 can be stored as text instead of numbers. Then a computer may put 20 before 3 because it compares the first characters, or refuse to add them. This seems reasonable because both kinds look the same on screen; the hidden type, not the appearance, controls the operation.
Where you meet types
Forms, games and drawing apps all use data types. A score is a number, your player name is text, a colour may be stored as several numbers, and a sound is a pattern of measurements. When you choose a date, type a message or change a photo, software is quietly deciding how each piece of information should behave.
Keep exploring
Other languages
Loading MyLeoNes™…