100% found this document useful (1 vote)
59 views22 pages

CSC 214 Digital Design

This document discusses number representation systems used in digital design, including binary, binary-coded decimal, octal, hexadecimal, and negative binary numbers. It covers converting between these systems and binary arithmetic. The key points are: - Computers use binary to represent numbers, while other bases like decimal, octal, hexadecimal are used by programmers for readability. - Binary can represent numbers in pure binary form or binary-coded decimal. Octal and hexadecimal represent numbers using groups of binary digits. - Converting a number between bases involves writing it in one base and converting the place values in that base to the other base. - Negative binary numbers use two's complement representation where the most significant bit

Uploaded by

faliciahassan3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
59 views22 pages

CSC 214 Digital Design

This document discusses number representation systems used in digital design, including binary, binary-coded decimal, octal, hexadecimal, and negative binary numbers. It covers converting between these systems and binary arithmetic. The key points are: - Computers use binary to represent numbers, while other bases like decimal, octal, hexadecimal are used by programmers for readability. - Binary can represent numbers in pure binary form or binary-coded decimal. Octal and hexadecimal represent numbers using groups of binary digits. - Converting a number between bases involves writing it in one base and converting the place values in that base to the other base. - Negative binary numbers use two's complement representation where the most significant bit

Uploaded by

faliciahassan3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 22

Digital Designs

S. O. ADEFAMOYE
Faculty of Sciences,
Computer Science Department
+234 – 809 – 073 – 1442
+229 – 6856 – 1587
Digital Designs Fundamentals 2

CHAPTER 1
INTRODUCTION TO NUMBERS AND CODES

1.0 Number representation: Computers can only process binary data – i.e. 1’s and 0’s. If
numeric data is to be processed then it cannot be processed in its usual base10 form, it must be
converted into its base2 form – known as binary.
There are two ways that can be used to represent numbers in binary:
 ‘pure’ binary;
 Binary-coded decimal (BCD).
There are also two ‘half-way’ stages that are sometimes used by programmers because they are
easier to understand than a string of 1s and 0s:
 Octal;
 Hexadecimal.

1.1 ‘Pure’ binary


Pure binary represents numbers using just two digits (‘0’ and ‘1’) and columns, which increase
by a factor of two.
This is in contrast to our normal number system (denary), which uses ten digits (0-9) and
columns, which increase by a factor of ten.
In denary the number one hundred and ninety seven is represented as:

In binary, it is represented as:

1.2 COUNTING IN BINARY

2
Digital Designs Fundamentals 3

1.2.1 Converting From Binary to Denary

1.2.2 Converting From Denary To Binary


A denary number, such as 107, can be converted into binary as follows:

1. Write down the binary column headings:

2. Then, starting from the left, ‘take out’ the values in the column headings, if possible:
128 cannot be taken out of 107 so that column contains a ‘0’:

64 can be taken out of 107 so that column contains a ‘1’; this leaves 107 – 64 = 43:

32 can be taken out of 43 so that column contains a ‘1’; this leaves 43 – 32 = 11:

3. keep repeating the above process until the whole number has been converted to pure
binary:

1.2.3 Binary Coded Decimal (BCD)


Binary Coded Decimal is one of the early memory encodings. Rather than converting the entire
denary value into its pure binary form, it converts each digit, separately, into its 4-bit binary
equivalent. The table below shows the 4-bit BCD equivalents of the ten denary digits:

3
Digital Designs Fundamentals 4

Note that the higher codes are not used in BCD because they do not represent a denary digit.
These are:

1.2.4 Converting from denary to BCD


Each digit is converted to its 4-bit BCD equivalent. Thus, the number 319 would be represented
in 12-bits as follows:

1.2.5 Converting from BCD to denary


Each group of 4-bits are converted into the equivalent denary digit. Thus, the 12-bit binary
coded decimal number 0110 1000 0011 is denary 683 as shown:

1.3 OCTAL NUMBER SYSTEM


The octal number system uses eight digits (0 to 7) to represent numbers, and columns which
increase by a factor of eight.

1.3.1 Converting from octal to denary


The octal number 652 would be converted to denary as shown:

4
Digital Designs Fundamentals 5

Converting between octal and binary. The octal number 652 (426 in denary) is represented in
binary as:

If we combine the bits in groups of three and label with the appropriate column headings…

… we can see that converting from octal to binary converts each digit into its 3-bit binary
equivalent (very similar as converting between denary and BCD).

Thus the octal equivalent of binary number 10011101 will be:

1.4 HEXADECIMAL NUMBER SYSTEM


The hexadecimal number system uses 16 digits to represent numbers. The denary digits 0 – 9
are used together with the first six letters of the alphabet (A – F).

With hexadecimal, instead of column headings doubling, as they do in binary, or increasing by a


factor of 10 as they do in denary, each column heading in hexadecimal increases by a factor of
16.
The column headings are:

Examples of hexadecimal numbers include: 3FC2, CFF8, 92B0, EE4D, ACDC.


Note that the number 9375 could either be ordinary denary or hexadecimal – to make it clear
the symbols ‘h’, ‘#’ or ‘&’ are often used. Thus, if the number was in hexadecimal, it would be
written as 9375h, #9375 or &9375.

1.4.1 Converting From Hexadecimal To Denary


The hexadecimal number 2C5A can be converted into its denary equivalent as follows:
1. Write the hexadecimal number with the appropriate column headings:
5
Digital Designs Fundamentals 6

2. Noting that A 10 and C 12, convert in the same way as conversion from binary to
denary:
= (4096 x 2) + (256 x 12) + (16 x 5) + (1 x 10)
= 11 354

1.4.2 Converting from hexadecimal to binary


This uses the same method as octal to binary, except each hexadecimal digit is represented by
4- bits. Thus, the hexadecimal number B7C can be converted into a 12-bit binary as follows:

1.4.3 Converting from denary to hexadecimal


Convert to binary first and then to hexadecimal. For example, 462 can be converted as follows:
First convert to binary:

Then convert each group of four into their hexadecimal equivalent:

= 1CE

1.5 USES OF HEXADECIMAL


Hexadecimal is often used by Assembly language programmers to reference memory. It is also
used within HTML property values – specifically background and font colours.
There are three advantages of using hexadecimal:
 Hexadecimal is quicker for a programmer to enter into a computer than binary;
 Hexadecimal is easier for a programmer to understand and remember – 8F8B is easier to
remember than 1000111110001011.
 It is very easy to convert between binary to hexadecimal.

1.5.1 Expression
Expressing the denary number 195 as eight-bit binary, BCD, octal and hexadecimal:

Binary

BCD

Octal
6
Digital Designs Fundamentals 7

Or:
Pure Binary:
Group in threes:
Octal:

Hexadecimal

Or:
Pure Binary:
Group in fours:
Hexadecimal:

1.6 NEGATIVE BINARY NUMBERS


Two’s compliment
Two’s compliment is a method of representing negative numbers in binary, whereby the most
significant bit maintains its magnitude, but is made negative.

If, for example, one byte is used to represent a ‘signed’ integer using the two’s compliment
method, the column headings would become:

Thus, the denary integer 18 would be represented as:

And the negative integer – 18 would be represented as:

Notes:
 Negative numbers will always start with a ‘1’ and positives will start will a ‘0’;
 The range of integers that can be represented using one byte is from – 128 up to + 127.

1.6.1 Converting a negative denary integer into two’s complement


Due to the way that binary numbers work, there is an easy ‘trick’ that allows very fast
conversion. Taking the denary integer – 52 as an example, you can use the three stages shown
below:
Stage one
Convert the positive form of the number into unsigned binary:

7
Digital Designs Fundamentals 8

Stage two
Starting at the right hand side, copy each bit, up to and including the first ‘1’:

Stage three
Reverse all the other bits:

This will always work – even if you do not understand why!

1.6.2 Converting a two’s complement number into denary


This is the same as converting any binary number into denary, as long as you remember that
the most significant bit is negative. For example the ‘signed’ binary number 1 1 0 1 0 1 0 1 is
converted as follows:

= – 128 + 64 + 16 + 4 + 1
= – 43

1.7 SIGN AND MAGNITUDE


The alternative to using two’s complement to represent negative numbers is to use the ‘sign
and magnitude’ method – here; the most significant bit is used as a sign bit without a numerical
value.

= – (64 + 8 + 4)
= – 76
Notes:
 The range of integers that can be represented using one byte is from – 127 up to + 127.
 Although the sign and magnitude method is easier for humans it is much harder to use for
computers performing arithmetic.

SPOT CHECK
1. Assuming a single byte is used, convert the following numbers into two’s compliment binary:
(a) – 5 (b) – 10 (c) – 20

2. What is the denary value of 1010 1011 if the binary codes represent:
(a) a two’s compliment number (b) a sign and magnitude number

8
Digital Designs Fundamentals 9

1.8 BINARY ARITHMETIC


1.8.1 Addition
Computers will only ever add two numbers at a time – if three numbers need to be added, a
computer will add the first two and then add the third number will be added to the result. Since
only two numbers are added at a time, there are limited outcomes:
0+0=0
0+1=1
1+0=1
1 + 1 = 2 (‘10’ in binary – this is 0 ‘down’ and ‘carry’ 1)

Note that when you add a ‘carry’ to the next column, it is possible for:
1 + 1 + 1 (the carry) = 3 (‘11’ in binary – this is 1 ‘down’ and ‘carry’ 1)
This is better shown if we add 1010 1110 1100 and 0011 1010 1010:

1.8.2 Subtraction
To perform subtraction, the number to be subtracted is converted into its two’s compliment
negative and then added.

For example to subtract 12 from 25:


1. Convert the 12 into two’s compliment –12

12

-12

2. Now add this to the 25:

Note that there is still a ‘carry’ bit, but this is ignored.


SPOT CHECK
1. Work out the following using binary addition and subtraction:
(a) 34 + 73 (b) 67 – 96

9
Digital Designs Fundamentals 10

CHAPTER 2
TEXT (CHARACTER) REPRESENTATION

2.0 Character Set


A character set are the characters that can be recognized by a computer.

2.1 Character encoding


A computer is able to represent four types of characters:
Alphanumeric characters – letters A – Z and a – z and the digits 0 – 9.
Punctuation characters and other ‘special’ symbols such as , . ; : “ ‘ ! @ £ $ % & * ( ) + <
Graphical characters such as ♣, ♦, ♥, ♠, , , , ✘, ☛, ✻ (and many more…);
Control characters – [Return], [Esc], [Space], [Alt], etc.
Within a computer, each character is represented using a unique binary code. Although there
are many different methods of encoding the characters, three of the most common are ASCII,
EBCDIC and Unicode.

ASCII
American Standard Code for Information Interchange (ASCII) is used for character encoding by
most Windows™ PCs. ASCII can be used to translate alphanumeric characters into a 7-bit binary
code that represents all the characters available from the keyboard including punctuation and
some special symbols such as ‘@’, # and $:

A development of ASCII, known as Extended ASCII, uses an 8-bit code that also defines codes for
additional characters, including some graphical ones. Note that using an 8-bit code means the
maximum number of characters that can be represented is 256.

2.2 How character encoding works


The diagram below shows how the message “Hello World” is stored in the memory of a
computer using the ASCII codes:

10
Digital Designs Fundamentals 11

The message is typed at the keyboard. Electronics in the keyboard convert the typed characters
into ASCII binary codes that are sent from the keyboard along a cable to the computer. The
computer stores these codes in its internal memory. The computer also provides a visual
display of the characters as they are typed. To be able to do this, electronics inside the
computer convert the stored binary codes back into their character equivalents.

EBCDIC
Extended Binary Coded Decimal Interchange Code (EBCDIC) was developed by IBM for use in
their mainframe systems. It has the same limitation as ASCII in that its 8-bit code can only
define 256 different characters.

11
Digital Designs Fundamentals 12

Notice how the EBCDIC codes are completely different to ASCII – if a message was sent that had
been encoded using ASCII, but received by a system that used EBCDIC, then the resulting
message would not make sense.

Unicode.
Unicode is an international system of representing characters using 16 bits. Using 16 bits means
that 216 = 65 536 different characters can be represented (thus overcoming the limitation of
ASCII and EBCDIC).

Unicode allows every character from most alphabets to have a code of its own – Chinese,
Russian, Greek, Urdu etc, including Egyptian Hieroglyphics. Note that there are plenty of spare
codes that are used for mathematical symbols, common graphics and even the Braille symbols.

Some of the Mongolian characters: Some of the Hebrew characters:

12
Digital Designs Fundamentals 13

CHAPTER 3

13
Digital Designs Fundamentals 14

14
Digital Designs Fundamentals 15

15
Digital Designs Fundamentals 16

16
Digital Designs Fundamentals 17

17
Digital Designs Fundamentals 18

18
Digital Designs Fundamentals 19

19
Digital Designs Fundamentals 20

20
Digital Designs Fundamentals 21

21
Digital Designs Fundamentals 22

22

You might also like