G3 Computing Textbook Chapter 02
G3 Computing Textbook Chapter 02
02 Data Representation
19
20
21
2.1 Introduction to Data Representation
As you have learned, in a computer, data is stored as bits. To work with various types of data, such as
numbers, text, images, and audio, this information must first be converted into bits that the computer can
understand. Different formats may be used for conversion depending on specific requirements and the
type of data being represented.
In this chapter, we will learn about how two types of data, numbers and text, are typically represented as
bits on a computer using number systems and extended ASCII respectively.
LEARNING OUTCOMES
1.2.2 Convert positive whole numbers from one number system to another - binary, denary
and hexadecimal; and describe the technique used.
0 1 2 3 4 5 6 7 8 9
Table 2.1 Digits of the denary number system
ER MS
KEY T
The number system that we are most familiar with and
typically use is called the denary number system. It
is also known as the decimal number system and is
Denary number system
made up of 10 distinct digits.
(or decimal number system)
A number system that is made up of 10
unique digits.
22
As the denary number system has 10 digits, it can
also be called a base-10 system. This is how we
count using the denary number system:
Place value=103 Place value=101
0 1 thousands 8 tens
1
2
Denary digit
1 2 8 9
Figure 2.3 shows how the value of 1289 can be calculated as the sum of each digit multiplied by its place value:
Note that 1289 does not have any digits to the left of (1 × 103) + (2 × 102) + (8 × 101) + (9 × 100)
the digit in the thousands place. The missing digits = 1289
in the ten thousands place and higher are thus
implied to be 0. These implied digits are usually Figure 2.3 Calculating the value of a denary number
left out for denary numbers, but may sometimes
be included, as leading zeros, when an exact
number of digits is needed. For instance, 1289 may
ER MS
be written as 001289 to use exactly six digits in KEY T
the denary number system. This may be useful to
make numbers printed in a column appear neater Leading zero
or easier to read. The zero digit (0) that is to the left of the
first non-zero digit in a number.
Figure 2.4 shows that 001289 still has a value of
1289 even with the leading zeros included:
Figure 2.4 Calculating the value of a denary number with leading zeros
23
Denary numbers with many digits can also be difficult to read. To make interpreting such numbers easier,
denary numbers larger than 999 are often shown with a separator (either a space or comma) after every
group of three denary digits, starting from the right. For instance, the number 1234567890 can also be
written as 1,234,567,890 or 1 234 567 890.
0 1
ER MS
Table 2.3 Digits of the binary number system
KEY T
As computers store data using bits or binary digits, Binary number system
they cannot use the denary number system with A number system that is made up of two
its 10 distinct digits directly. Instead, they use the unique digits.
binary number system that is made up of two
distinct digits, 0 and 1, to store numbers.
As the binary number system has two digits, it can also be called a base-2
system. This is how we count using the binary number system:
The position of a digit in a binary number determines its place value, which is represented by 2N. The place
value starts from 20 for the rightmost digit, with the power (N) increasing by 1 for each subsequent digit on
the left, as shown in Figure 2.6. This means that the place value of each digit in the binary number system
is two times the place value of the digit on its immediate right.
Place value=23 Place value=21 To distinguish binary numbers from denary numbers,
the binary numbers are appended with the number 2
as a subscript, like this: 11012. Alternatively, the binary
24
U
DID YO
O W ?
is defined to have exactly eight binary digits.
Leading zeros are often needed so that all K N
eight binary digits of each byte are shown.
Another acceptable way to write binary
For readability, large binary numbers may numbers is to enclose the binary digits in
also be shown with a separator (usually a parentheses, like this: (1101)2. This format is
space) between groups of four digits, starting less ambiguous in situations where normal
from the right. For instance, the binary digits and subscript digits may appear similar
number 100101102 can also be written as in handwriting.
1001 01102.
To convert a binary number to its denary equivalent, we use the sum of place
values method, i.e., sum the product of each digit and its place value. Let us use
the binary number 11 10012 as an example.
256 128 64 32 16 8 4 2 1
Place value
28 27 26 25 24 23 22 21 20
Binary digit 1 1 1 0 0 1
There are two methods of converting denary numbers to binary numbers. As an example, let us convert the
denary number 135 to a binary number using each of these methods.
25
2.2.2.2.1 Method 1: Division by 2
135 67 1
67 33 1
33
26
This sequence is repeated until the last iteration when the denary number
reaches 1. In this case, 1 ÷ 2 gives a quotient of 0 and a remainder of 1. As the
quotient is 0, we proceed to Step 5 of the algorithm.
135 67 1
67 33 1
33 16 1
Direction to read
16 8 0
the digits
8 4 0
4 2 0
2 1 0
1 0 1
STEP 5
The equivalent To obtain the converted binary number, read the digits in the
binary number is the ‘Remainder’ column from the bottom upwards. Hence, the
remainder column binary equivalent of 135 is 1000 01112.
read from the bottom
up.
In each column, write out the place value of each position in a binary number.
In the last column, write down the denary number we wish to convert, i.e., 135.
STEP 1
Place 256 128 64 32 16 8 4 2 1 Denary
Write out the place value
value of each position in 135
a binary number. 28 27 26 25 24 23 22 21 20
Binary
digit
27
STEP 2
Find the highest place value that is equal to or less than 135. In this case, 27 (or
Find the highest place 128) is the highest place value that is less than 135, so we write ‘1’ under the 27
value that is equal column as shown in Table 2.10.
to or less than the
denary number.
STEP 3 Subtract the place value 128 from 135 and update the result ‘7’ in the ‘Denary’
Fill in the binary digit 1 column, as shown in Table 2.10. As the result is not zero, we repeat Step 2 of
below this place value. the algorithm with the number 7.
Subtract the place value 4 from 7 and update the result ‘3’ in the ‘Denary’
column, as shown in Table 2.11. As the result is not zero, we repeat Step 2 of
the algorithm with the number 3.
Table 2.11 Second iteration of Steps 2 to 4 in the sum of place values method
28
Following the same method, we place ‘1’s under 21 and 20 columns. As the final
number is now 0, we continue with Step 5 of the algorithm.
The binary digit for each place value column is then combined in sequence to form the binary number.
Hence, the binary equivalent of 135 is 1000 01112.
0 1 2 3 4 5 6 7 8 9 A B C D E F
Table 2.14 Digits of the hexadecimal number system
29
The hexadecimal number system is also known as the base-16 system.
To count using the hexadecimal number system, we use the following method:
0
1
2
This method of counting illustrates how digits “A” to “F” are equivalent to the denary values of 10 to 15
respectively, as shown in Table 2.15.
Hexadecimal digit 0 1 2 3 4 5 6 7 8 9 A B C D E F
Denary value 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
To distinguish hexadecimal numbers from binary and denary numbers, they are often written with a
subscript ‘16’, e.g., 1C6A16. Alternatively, hexadecimal numbers may also be prefixed with the characters
“0x”, e.g., 0x1C6A.
U
DID YO
?
K NOW
As with binary numbers, another acceptable way of writing hexadecimal
numbers is to enclose the hexadecimal digits in parentheses, like this:
(1C6A)16.
30
Just like denary and binary numbers,
U
leading zeros do not affect the value of
DID YO
KNOW?
hexadecimal numbers but may be shown
when an exact number of digits is needed.
This is common when using hexadecimal
numbers in computer systems as each byte
needs at most two hexadecimal digits to An easy way to convert values between different
be shown in full. Leading zeros are often number systems is to use the Calculator app on your
needed so that each byte can be expressed computer. In Windows operating systems, you can
using exactly two hexadecimal digits. find this app under the Programs/Apps folder of the
Start Menu. In Mac operating systems, you can find
For readability, hexadecimal numbers with this app in the Applications folder. For either version,
more than three digits may also be shown set the calculator to Programmer mode by clicking
with a separator (usually a space) between on the “View” menu and selecting “Programmer”
groups of two or four digits, starting from to perform conversions between different number
the right. For instance, the hexadecimal systems.
number 1C6A16 can also be written as
1C 6A16.
To convert a hexadecimal number to its binary equivalent, we map each hexadecimal digit to its four-digit
binary equivalent as shown in Table 2.16.
Hexadecimal digit 0 1 2 3 4 5 6 7
Binary value 0000 0001 0010 0011 0100 0101 0110 0111
Hexadecimal digit 8 9 A B C D E F
Binary value 1000 1001 1010 1011 1100 1101 1110 1111
3 Finally, the sets of binary digits in Table 2.17 are combined Table 2.17 Converting 3C16 to binary
sequentially to form the equivalent binary number.
Hence, the binary equivalent of 3C16 is 0011 11002,
which is the same as 11 11002 if the leading zeros are
omitted.
31
As another example, let us convert CF 0716 to its binary equivalent.
Starting from the right, we split the number into four-digit groups, as shown
STEP 1 in Table 2.19.
STEP 2 Since the final group on the left only contains two digits, we add two leading
If the final set of zeros to its left such that it now has four digits, as shown in Table 2.20.
remaining digits on the
left does not have four
digits, we add leading 0010 1000 0110 1011
zeros to the set such
that it has exactly four Table 2.20 Add leading zeros to the final group on the
binary digits. left if it does not have four digits
Using Table 2.16, we write down the equivalent hexadecimal digit for each
group of four binary digits as shown in Table 2.21.
STEP 3
Using Table 2.16 as
a reference, map
Binary digits 0010 1000 0110 1011
each four-digit group Hexadecimal digit 2 8 6 B
to its corresponding
hexadecimal digit.
Table 2.21 Converting each group of four binary digits
into a hexadecimal digit
STEP 4
Combine the Finally, the hexadecimal digits in Table 2.21 are combined sequentially to
hexadecimal digits form the equivalent hexadecimal number. Hence, the hexadecimal equivalent
sequentially to of 10 1000 0110 10112 is 28 6B16.
form the equivalent
hexadecimal number.
32
2.2.3.3 Converting From Hexadecimal to Denary
From Table 2.15, the denary values of ‘C’, ‘7’ and ‘F’ are 12, 7 and 15
respectively.
Denary equivalent 12 7 15
Multiply the denary equivalent of each digit with its place value as
STEP 2 shown in Figure 2.10 and sum up the products.
Multiply each
denary value by the (12 × 162) + (7 × 161) + (15 × 160) = 3072 + 112 + 15 = 3199
respective 16N place
Figure 2.10 Converting C7F16 to denary
values.
STEP 3
Sum the results of Hence, the denary equivalent of C7F16 is 3199.
each place value.
There are two methods of converting denary numbers to hexadecimal numbers. As an example, let us
convert the denary number 1899 using each of these methods.
In this method, we divide the denary number repeatedly by 16. This is similar to the ‘division by 2’
method in section 2.2.2.2.1 used to convert a denary number to binary. The remainders of the divisions
are then used to derive the hexadecimal number.
33
The general algorithm is as follows:
Using 1899 as an example:
STEP 1
Draw a table with three columns and write down 3 headings – ‘Denary’,
Draw a table with
‘Quotient’ and ‘Remainder’. In the first row of the ‘Denary’ column, write down
three columns – one
the denary number that we wish to convert, i.e, 1899.
column for denary
numbers, one column
for the quotients and
one column for the Denary Quotient Remainder
remainders.
1899
STEP 2
Fill in the denary
number in the first row. Divide the denary number 1899 by 16 and write down its quotient and
remainder in the respective columns of the same row. In this case, 1899 ÷ 16
gives a quotient of 118 and a remainder of 11. As the quotient 118 is not zero,
copy 118 to the next row of the ‘Denary’ column, then repeat Step 3 of the
algorithm.
STEP 3
Divide the denary
number by 16 and Denary Quotient Remainder
fill in its quotient
and remainder in the 1899 118 11
same row.
118
1899 118 11
118 7 6
34
Divide the denary number 118 by 16 and write down its quotient and remainder
in the respective columns of the same row. In this case, 118 ÷ 16 gives a quotient
of 7 and a remainder of 6. As the quotient 7 is not zero, copy 7 to the next row of
the ‘Denary’ column, then repeat Step 3 of the algorithm.
1899 118 11
118 7 6
7 0 7
Direction to read
Convert the
numbers in the
remainder column to 118 7 6= 616
the digits
hexadecimal digits.
7 0 7= 716
STEP 6
The converted To obtain the converted hexadecimal number, read the hexadecimal
hexadecimal number digits in the ‘remainder’ column upwards from the bottom. Hence,
is the remainder the hexadecimal equivalent of 1899 is 76B16.
column read from the
bottom up.
In this method, we put hexadecimal digits under the place values, starting from the left, so that the
total adds up to the value that we want to convert. This method is similar to the sum of place values
method used in section 2.2.2.2.2 to convert from a denary number to binary. However, it is significantly
more complex as there are more digits to work with in the hexadecimal number system compared to
the binary number system.
35
The general algorithm is as follows:
Using the denary number 1899
as an example:
STEP 1 In each column, write out the place value of each position in a hexadecimal
number. In the last column, write down the denary number we wish to convert,
Write out the place
i.e., 1899.
value of each position
in a hexadecimal
number. 65536 4096 256 16 1 Denary
Place value
164 163 162 161 160 1899
Hexadecimal
STEP 2 digit
Find the highest place
value that is equal to Table 2.28 Step 1 in the sum of place values method
or less than the denary
Find the highest place value that is equal to or less than the denary number
number.
1899. In this case, 162 (or 256) is the highest place value that is less than 1899.
STEP 3
Fill in the largest Under the column of 162, we fill in the largest hexadecimal digit such that its
hexadecimal digit product with 162 is equal to or less than 1899. Since 716 × 162 (= 1792) is less
below this place than 1899 and 816 × 162 (= 2048) is greater than 1899, the largest hexadecimal
value whose product digit needed here is 716, as shown in Table 2.29.
with this place value
is equal to or less
than the denary
number.
Subtract the product 1792 from 1899 and update the result ‘107’ in the denary
column, as shown in Table 2.29. As the result is not zero, we repeat Step 2 of
the algorithm with the number 107.
STEP 4
Subtract this product
from the denary 65536 4096 256 16 1 Denary
number. If the result Place value
is 0, proceed to Step 164 163 162 161 160 1899
5. Otherwise, repeat 107
Step 2. Hexadecimal
7
digit
Table 2.29 First iteration of Steps 2 to 4 in the sum of place values method
Find the highest place value that is equal to or less than the denary number
107. In this case, 161 (or 16) is the highest place value that is less than 107.
Hence, under the column of 161, we fill in the largest hexadecimal digit such
that its product with 161 is equal to or smaller than 107. Since 616 × 161 (= 96) is
less than 107 and 716 × 161 (= 112) is greater than 107, the largest hexadecimal
digit needed here is 616, as shown in Table 2.30.
Subtract the product 96 from 107 and update the result ‘11’ in the ‘Denary’
column, as shown in Table 2.30. As the result is not zero, we repeat Step 2 of the
algorithm with the number 11.
36
65536 4096 256 16 1 Denary
Place value
164 163 162 161 160 1899
107
Hexadecimal 11
7 6
digit
Table 2.30 Second iteration of Steps 2 to 4 in the sum of place values method
Find the highest place value that is equal to or less than the denary number
11. In this case, 160 (or 1) is the highest place value that is less than 11. Hence,
under the column of 160, we fill in the largest hexadecimal digit whose product
with 160 is equal to or smaller than 11. Since B16 × 160 (11 × 1 = 11) is equal to 11,
the hexadecimal digit needed here is B16, as shown in Table 2.31.
Subtract the product 11 from 11, which gives us 0, as shown in Table 2.31. As
the result is 0, we can proceed to Step 5 of the algorithm.
Table 2.31 Last iteration of Steps 2 to 4 in the sum of place values method
STEP 5
Fill in the
Fill in 0s under the remaining place values. In this case, all the place values
hexadecimal digit 0
after the first not zero hexadecimal digit are already filled.
below any remaining
place values.
STEP 6
The equivalent
hexadecimal number Hence, the hexadecimal equivalent of 1899 is 76B16.
is formed by the row
of hexadecimal digits
below the place
values.
37
QUICK 2
C K 2.
CHE
1. Convert the following denary numbers to binary using both the division by 2 and sum of place values methods:
a) 54
b) 89
c) 100
4. The largest number that can be represented by N bits is obtained when all the N bits are set to 1. The following
is a table of the largest numbers that can be represented by N bits, where N = 1 to 5, expressed in both binary
and denary:
N Binary Denary
1 12 1=2-1
2 112 3=4-1
3 1112 7=8-1
4 11112 15 = 16 - 1
5 111112 31 = 32 - 1
b) By observing a pattern or through other means , express the largest number that can be represented using
N bits in terms of N
5. At least 16 bits are required to represent the sum of two 8-bit numbers. True or false?
6. Write down the hexadecimal and binary equivalents of the denary values from 32 to 47.
38
2.3 Representing Negative Numbers
LEARNING OUTCOMES
1.2.3 Use two’s complement for a fixed number of bits to represent both positive and negative
whole numbers in binary.
So far, we have only used bits and the binary number system to represent zero and positive integers.
However, computers often use bits to represent negative integers as well.
U
DID YO
?
K NOW
There are many ways to represent negative integers in binary form on a
computer. One simple way is to reserve the first bit (the leftmost bit) of a binary
number to represent the positive sign (0 as ‘+’) or negative sign (1 as ‘-‘). The
remaining bits then represent the magnitude (size) of the positive or negative
integer. For instance, with 3 bits, 001 would represent integer ‘1’ and 101 would represent the integer ‘-1’.
This is called the sign-magnitude representation.
Unfortunately, this representation has some disadvantages. For instance, in this representation, there are
two ways to represent zero (e.g., with 3 bits, 000 and 100 both represent 0). The steps for performing
binary arithmetic operations also differ depending on whether sign-magnitude representation is used or
not. These disadvantages make the sign-magnitude representation more difficult to work with in practice
and so it is not used by most modern computers.
In most computers, negative integers are represented using a system where a fixed number of bits are used
to represent each integer. For simplicity, suppose we have a computer where each integer is represented
by 3 bits. Figure 2.11 shows a number line of all the positive integers that can be represented using 3 bits,
starting from 0 to 7 (= 23 – 1). The numbers are shown as bits above the line and their corresponding integer
values are below the line:
To represent negative integers, we shift the numbers to the right such that zero is near the centre, as shown
in Figure 2.12. We then transfer (or wrap) the higher order bits that begins with 1 to the left end of the
number line, keeping them in the same sequence. However, instead of representing positive integers (4, 5,
6, 7), these bits now represent negative integers (-4, -3, -2, -1).
39
Keeping the same relative order allows the processor to perform the same binary addition and subtraction
operations for both positive and negative integers.
Subtraction 3 0 1 1
- 1 - 0 0 1
2 0 1 0
Figure 2.13 Addition and subtraction of positive integers in denary and 3-bit two’s complement
This is especially true when transitioning between ‘-1’ (represented by 111) and ‘0’ (represented by 000).
This is because given a fixed number of bits, binary operations that result in a binary values which that
exceeds the limits of the representable range will simply “wrap around” such that the final bit representation
stays within the range. This behaviour is called integer overflow.
• For instance, adding 1 to 1112 (represented by 111) should produce 10002, but this result cannot
be represented using 3 bits, so it is “wrapped around” to produce 000. Note that this is consistent
with the interpretation where 111 represents ‘-1’ and 000 represents ‘0’.
-1 1 1 1
+ -3 + 1 0 1
-4 1 1 0 0
Figure 2.14 Addition of negative integers in denary and 3-bit two’s complement
As a result of the shift shown in Figure 2.12, the bit representation of numbers that are the negative of each
other (e.g., 3 and -3) can be converted from one to the other by calculating the two’s complement.
The two’s complement is defined as 2N minus the number (where N is the number of bits).
• For instance, 3 is represented by 011 using 3 bits. The two’s complement is 23 – 0112 = 8 – 3 = 5 =
1012. This corresponds to 101, which represents -3.
• Conversely, -3 is represented by 101 using 3 bits. The two’s complement is 23 – 1012 = 8 – 5 = 3 =
0112. This corresponds to 011, which represents 3.
Figure 2.15 Numbers that are negative of each other are related by two’s complement
40
U
Instead of performing denary arithmetic operations to calculate
DID YO
KNOW?
2N minus the number, a quicker method (both for humans and
the computers) is to perform simple binary operations as follows:
QUICK
E CK 2 .3
CH
1. Represent the following numbers using 4-bit two’s complement:
a) 5
b) -5
c) 7
d) -7
e) -8
2. Both 8 and -8 can be represented using 4-bit two’s complement. True or False?
3. The following sets of 8 bits use two’s complement to represent negative numbers. Write down the number
being represented by each set of 8 bits.
a) 1100 1010
b) 0101 0011
c) 1111 1111
d) 1000 0000
41
2.4 Representing Text
LEARNING OUTCOMES
1.2.4 Use the example of an 8-bit extended ASCII encoding for English text to explain how
information can be represented as bits for storage or processing by a computer.
U
DID YO
?
KNOW
ASCII was developed in an era where teleprinters or teletypewriters were commonly used for
communication.
Prior to the use of magnetic storage media, these devices encoded information digitally on paper
tapes by punching holes in them. A punched hole represented 1 while a position with no hole
represented 0. The image below shows how 8 bits in a row are used to represent a character, with
7 bits for ASCII encoding and 1 additional bit on the left, known as the parity bit (see Chapter 10).
Figure 2.16 Teletype Model 33 with paper tape Figure 2.17 Segment of a punched paper tape
reader and punch on its left side showing sequences of 8 bits
42
U
Subsequent Extended ASCII standards then DID YO
?
K NOW
used 1 byte (8 bits) for each character, so they
could represent an additional 128 characters
for a total of 28 = 256 distinct characters.
The name “Extended ASCII” can refer to several
With Extended ASCII, the 256 characters are standards. For languages like English that
represented by numbers from 0000 00002 are based on the Latin alphabet, “Extended
to 1111 11112, which is the same as 0016 to ASCII” often refers to the “Latin 1” standard
FF16 or 0 to 255. Hexadecimal digits are often defined by the International Organisation for
used to express Extended ASCII codes as two Standardisation (ISO).
hexadecimal digits correspond exactly to 1 byte
or 1 character. This is more compact than using The first 32 ASCII codes (0 to 31) represent non-
three denary digits or eight binary digits. printing characters that are not written symbols
or the space character. These codes are used to
Table 2.32 shows how the ASCII codes from 32 to perform special functions on devices (such as
127 may be expressed using the denary (base- the Teleprinter in Figure 2.16) or to represent
10), binary (base-2) and hexadecimal (base-16) special input such as typing the Backspace and
number systems along with the corresponding Esc keys on the keyboard. The last ASCII code
characters being represented. 127 is also used to represent the special input of
typing the Delete key on the keyboard.
43
Base-10 Base-2 Base-16 Character Base-10 Base-2 Base-16 Character
Table 2.32 ASCII codes converted to binary and hexadecimal numbers and their corresponding characters
44
U
DID YO
N O W ? Besides ASCII, an expanded standard called Unicode is used to represent
K characters in languages other than English such as Tamil and Mandarin. Like
ASCII, the Unicode standard uses numbers to represent characters. However,
while Extended ASCII codes are defined to be exactly 1 byte long, Unicode is not
as restrictive. In Unicode, the number of bits used to represent each character can vary from 8 to 32 bits
depending on the encoding scheme used. This flexibility means that Unicode can be used to represent over
a million unique characters from many written languages around the world, which makes it the preferred
choice over the ASCII standard.
QUICK 4
C K 2.
CHE
1. Use an ASCII table (such as Table 2.32) to determine the ASCII code for the following characters:
a) @
b) z
c) 1
d) (space)
e) ?
2. Decode the following sequence of bytes using an ASCII table. Each byte represents a character and is
encoded as 2 hexadecimal digits:
51 75 69 65 74 2C 20 70 6C 65 61 73 65 21
W
REVIE
E STI ON
Q U
1. Why is the hexadecimal number system preferred over the binary number system in representing large
numbers?
45
W
REVIE N
S TI O
QUE
4. a) Convert the denary number 108 to an 8-bit binary number.
b) Convert the denary number 108 to hexadecimal.
b) By observing a pattern, describe how -1 is generally represented using two’s complement for N bits.
6. A lift system in a building uses eight bits to store some important information per lift, as shown in Figure
2.18. The first four bits indicate whether any of the four sensors has picked up a fault (denoted by the value
1) in any of the subsystems. The last four bits indicate the lift number. There are 15 lifts in the building.
Place values 8 4 1 2
Lift
number
Display Lighting Motor Ventilator
sensor sensor sensor sensor
For example, the bits shown in Figure 2.19 indicates that there are faults in the lighting and motor
subsystems for lift number 3.
0 1 1 0 0 0 1 1
Figure 2.19 Bits indicating that lift number 3 has faults in the
lighting and motor subsystems
1 0 1 0 0 1 1 1
Figure 2.20 Bits for lift system
0 0 1 1 1 0 1 1
Figure 2.21 Bits for lift system
c) What would be the bits if there were faults in the display and lighting subsystems for lift number 14?
Give your answer as a binary number.
46
W
REVIE N
S TI O
QUE
7. In a factory, there are 127 electrical points that provide power to various machinery. Eight bits are used
to represent the state of each electrical point. The first bit indicates the operational state of the electrical
point: a value of 1 means that it is operational and a value of 0 means that it is faulty. The next seven bits
indicate the electrical point number.
For example, the eight bits shown in Figure 2.22 indicates that electrical point number 41 is operational.
Place values 64 32 16 8 4 2 1
1 0 1 0 1 0 0 1
Figure 2.22 Bits indicating that electrical point number 41 is operational
Place values 64 32 16 8 4 2 1
1 0 1 1 1 0 0 0
Figure 2.23 Bits for electrical point
b) What would be the bits if electrical point number 36 was faulty? Give your answer as an eight-bit binary
number.
c) Convert the number indicated by the bits shown in Figure 2.24 to hexadecimal.
1 0 0 1 1 1 0 0
Figure 2.24 Bits for electrical point
47
ANSWER
b) 101 10012
Using the division by 2 method:
Denary Quotient Denary
89 44 1
44 22 0
22 11 0
Direction to
11 5 1
read the digits
5 2 1
2 1 0
1 0 1
c) 110 01002
Using the division by 2 method:
Denary Quotient Denary
100 50 0
50 25 0
25 12 1
12 6 0 Direction to
6 3 0 read the digits
3 1 1
1 0 1
48
ANSWER
3. a) 19
b) 96
c) 134
b) The largest number that can be represented using N bits is 2N – 1. (As observed in the table.)
5. False. The largest 8-bit number is 1111 11112 = 255, so the sum of two 8-bit numbers is at most 255 + 255 = 510,
which is 1 1111 11102 in binary and requires only 9 bits, not 16.
49
ANSWER
2. False.
(The range of values that can be represented using 4-bit two's complement is from -23 to 23 – 1 which is -8 to 7,
hence -8 can be represented but 8 cannot.)
3. Hint: if the first bit is 1 (negative sign), then perform two’s-complement to find its magnitude (positive
complement)
a) -54
b) 83
c) -1
d) -128
2.
Code 51 75 69 65 74 2C 20 70 6C 65 61 73 65 21
Char. Q u i e t , p l e a s e !
1. When representing large numbers, the hexadecimal form is much shorter than the binary form, making it more
compact for communication.
2. a) 10102
b) 1111 11112
c) 1 0000 10112
50
ANSWER
3. a) D16
b) 916
c) 516
d) ED16
e) 5516
f) 16 CD16
4. a) 0110 11002
b) 6C16
5. a)
i. 11
ii. 1111
iii. 111111
b) When using two's complement for N bits, -1 is represented by setting all N bits to 1.
6. a) There are faults in the display and motor subsystems for lift number 7.
b) There are faults in the motor and ventilator subsystems for lift number 11.
c) 11001110
51