DATA
Computers understand only two states: power on, or power off. This is
represented by switches, and computers are essentially calculators made
up of billions of switches. Computers use a binary number system
consisting of only 0s and 1s. Everything that a computer needs to process
must be converted into a binary format. This format is used for storing
numbers, text, sound, graphics, and program instructions. Computers
comprise billions of switches to turn current on and off.
Many units are used for data storage in computers:
1 bit = a single 0 or 1
1 nibble = 4 bits (half a byte)
1 byte = 8 bits = 1 character of text
1 KiB (kibibyte) = 1024 bytes
1 MiB (mebibyte) = 1024 KiB or 1024x1024 bytes
1 GiB (gibibyte) = 1024 MiB
1 TiB (tebibyte) = 1024 GiB
Number of switches (bits) Possible combinations/states
1 2
2 4
3 8
4 16
5 32
6 64
7 128
8 256
The most significant bit (MSB) is the bit with the largest value.
This is the bit that is furthest to the left.
The least significant bit (LSB) is the bit with the smallest value.
This is the bit that is furthest to the right.
Counting in binary
RULE 1: 0+0=0
RULE 2: 1+0=1
RULE 3: 0+1=1
RULE 4: 1+1=0 carry 1
RULE 5: 1+1+1=1 carry 1
Hexadecimal (or hex) is a number system which uses base 16. As we only
have 10 digits, it uses 0-9 and then the letters A to F
Denar 0 1 2 3 4 5 6 7 8 9 10 1 12 13 14 15
y 1
Hex 0 1 2 3 4 5 6 7 8 9 A B C D E F
, There are advantages for programmers and Computer Scientists in using
hex rather than binary.
It is much simpler to remember a hex value than a binary value.
It is quicker to write or type since a hex digit only takes up one digit
rather than 4 bits.
People are less likely to make an error with fewer digits.
It is easy to convert between hex and binary
A logical shift moves all of the bits in a given binary either to the left or
the right by a given number of places. All of the empty spaces are then
filled with zeros.
A left arithmetic shift is identical to a left logical shift. The result of a left
shift is to multiply the number by 2n where n is the number of places
shifted. However, if the left-most (the sign bit) is change by the shift,
overflow results.
With a right arithmetic shift of one place, each bit moves by one place.
The right-most bit is discarded, and the left-most bit is filled with the
previous value. This preserves the sign bit. Each shift right divides by two.
There may be a loss of precision
Two’s complement is a method of storing both positive and negative
integers in 8-bit binary. In a two’s complement number, if the leftmost bit
is a zero, then the number works just as with a normal binary number. If a
two’s complement number is stored in 8-bits, then it cannot store a
number greater than +127. Arithmetic left shifts are the same as for
logical shifts.
Every character is represented by a binary value. Capital letters have
different values to lowercase characters. Punctuation has their own
character code. A keyboard contains:
26 lowercase letters
26 uppercase letters
10 numbers
(around) 36 other characters
There are around 98 unique characters that are available on a
keyboard
6 bits give 64 different combinations – this isn’t enough
7 bits give 128 different combinations which can represent 128 different
characters
ASCII (American Standard Code for Information Interchange) has become
the standard code, used worldwide. It was originally developed in the
1960s for representing the English alphabet. It encodes 128 characters
into 7-bit binary codes. Characters include numbers 0 to 9, uppercase and
lowercase letters A-Z, a-z, punctuation symbols and the space character.
Computers understand only two states: power on, or power off. This is
represented by switches, and computers are essentially calculators made
up of billions of switches. Computers use a binary number system
consisting of only 0s and 1s. Everything that a computer needs to process
must be converted into a binary format. This format is used for storing
numbers, text, sound, graphics, and program instructions. Computers
comprise billions of switches to turn current on and off.
Many units are used for data storage in computers:
1 bit = a single 0 or 1
1 nibble = 4 bits (half a byte)
1 byte = 8 bits = 1 character of text
1 KiB (kibibyte) = 1024 bytes
1 MiB (mebibyte) = 1024 KiB or 1024x1024 bytes
1 GiB (gibibyte) = 1024 MiB
1 TiB (tebibyte) = 1024 GiB
Number of switches (bits) Possible combinations/states
1 2
2 4
3 8
4 16
5 32
6 64
7 128
8 256
The most significant bit (MSB) is the bit with the largest value.
This is the bit that is furthest to the left.
The least significant bit (LSB) is the bit with the smallest value.
This is the bit that is furthest to the right.
Counting in binary
RULE 1: 0+0=0
RULE 2: 1+0=1
RULE 3: 0+1=1
RULE 4: 1+1=0 carry 1
RULE 5: 1+1+1=1 carry 1
Hexadecimal (or hex) is a number system which uses base 16. As we only
have 10 digits, it uses 0-9 and then the letters A to F
Denar 0 1 2 3 4 5 6 7 8 9 10 1 12 13 14 15
y 1
Hex 0 1 2 3 4 5 6 7 8 9 A B C D E F
, There are advantages for programmers and Computer Scientists in using
hex rather than binary.
It is much simpler to remember a hex value than a binary value.
It is quicker to write or type since a hex digit only takes up one digit
rather than 4 bits.
People are less likely to make an error with fewer digits.
It is easy to convert between hex and binary
A logical shift moves all of the bits in a given binary either to the left or
the right by a given number of places. All of the empty spaces are then
filled with zeros.
A left arithmetic shift is identical to a left logical shift. The result of a left
shift is to multiply the number by 2n where n is the number of places
shifted. However, if the left-most (the sign bit) is change by the shift,
overflow results.
With a right arithmetic shift of one place, each bit moves by one place.
The right-most bit is discarded, and the left-most bit is filled with the
previous value. This preserves the sign bit. Each shift right divides by two.
There may be a loss of precision
Two’s complement is a method of storing both positive and negative
integers in 8-bit binary. In a two’s complement number, if the leftmost bit
is a zero, then the number works just as with a normal binary number. If a
two’s complement number is stored in 8-bits, then it cannot store a
number greater than +127. Arithmetic left shifts are the same as for
logical shifts.
Every character is represented by a binary value. Capital letters have
different values to lowercase characters. Punctuation has their own
character code. A keyboard contains:
26 lowercase letters
26 uppercase letters
10 numbers
(around) 36 other characters
There are around 98 unique characters that are available on a
keyboard
6 bits give 64 different combinations – this isn’t enough
7 bits give 128 different combinations which can represent 128 different
characters
ASCII (American Standard Code for Information Interchange) has become
the standard code, used worldwide. It was originally developed in the
1960s for representing the English alphabet. It encodes 128 characters
into 7-bit binary codes. Characters include numbers 0 to 9, uppercase and
lowercase letters A-Z, a-z, punctuation symbols and the space character.