
Data inside the computer is represented in form of electrical pulses, when high voltage is often denoted by 1 (or on) and low voltage is denoted by 0 (or off).
Because we are using only two digits, 0 and 1, for data representation we are actually using the binary number system, where 0 and 1 are often referred to as binary digits. The abbreviation of "binary digit", bit, is accepted as a basic unit when we measure amounts of information. All keys on the keyboard are coded with the combination of 0s and 1s. When you press any key, a corresponding sequence of 0s and 1s is sent to the memory inside the computer (see an example of what happens when a user presses keys on a keyboard).
When a computer gets the sequence of binary digits, how can it know when the first character stops and the next one starts? The easiest solution was to make all characters to consist of the same number of digits. But how many digits?
First how many characters do we need to code? 26 upper case letters, 26 lower case letters, 10 decimal digits, punctuation and lots of special characters. Altogether to cover all these characters and all keys on the keyboard we need 256 codes. With one digit we can code two characters only. With two digits we can code 22 = 4 characters. If we proceed this way, we'll get the following table of powers of 2:

From the table we can see that to represent 256 characters we need 8 digits. What to do if the binary representation of a character is less than 8 digits? For example, upper case letter A is coded as 65 using decimal system which is 1000001 in binary. There are only 7 digits here. Place leading 0 (zero) and you get 8 digits without changing the actual value of the number (like in decimal system 5, 05 or 005 will have the same value).
| So every character occupies 8 bits of memory or 8 bits of secondary storage. The word "HELLO." consists of 6 characters (5 letters and one full stop) and occupies 6*8=48 bits. The word "computer" consists of 8 characters and occupies 8*8=64 bits. Whatever amount of information you measure in bits, you will always get a multiple of 8. That is why another unit of measure, called byte, was introduced. | ![]() |
A group of 8 bits is called a byte.
As amounts of data being processed keep growing, other units of measure were created.
1 Kilobyte = 1024 bytes
Outside computing, a kilo means 1000. However, in computer environment, all measures should be powers of 2 and closest to 1000 will be 1024 which is 210. Kilobyte is often abbreviated as K or Kbyte.
Today computer memory is measured in thousands of kilobytes or Megabytes and secondary storage is measured in millions of kilobytes or Gigabytes. A Megabyte is often represented as Mbyte or M. A Gigabyte is abbreviated as G.
1 Megabyte = 1024 K = 10242 bytes
1 Gigabyte = 1024 M = 10242 K = 10243 bytes
1 Terabyte = 1024 G = 10242 M = 10243 K = 10244 bytes
In programming languages, a variable is a named memory location created to keep data. But what amount of data? This depends on the type of the variable. If a variable is of type character, it will occupy only 1 byte of memory. A variable of type integer on a personal computer in most programming environments will occupy 2 bytes of memory. For example, if variable named Number is of type character and holds the value of `4' it will occupy only one byte. But if it is of type integer with the value 4, it will occupy 2 bytes.
![]()
![]() | ![]() |