0% found this document useful (0 votes)
77 views37 pages

1.0 Numbering Systems

The document discusses various numbering systems used in computers including binary, decimal, octal, and hexadecimal. It provides details on how each system represents values and examples of converting between the different bases. Key points covered include how binary uses two digits of 0 and 1, with each digit called a bit, and how hexadecimal uses 16 digits and is more compact than binary. Conversion between the systems involves dividing the value by the new base and recording the remainders.

Uploaded by

Praise Phillips
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views37 pages

1.0 Numbering Systems

The document discusses various numbering systems used in computers including binary, decimal, octal, and hexadecimal. It provides details on how each system represents values and examples of converting between the different bases. Key points covered include how binary uses two digits of 0 and 1, with each digit called a bit, and how hexadecimal uses 16 digits and is more compact than binary. Conversion between the systems involves dividing the value by the new base and recording the remainders.

Uploaded by

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

1.

0 Numbering Systems

• Most modern computer systems do not represent numeric values using


the decimal numbering system. They use the binary or two’s complement
numbering system.

• But when dealing with a computer at the machine level, we must be more
concerned with how data are stored.

• Hence the job of converting data from one representation to another


must be carried out.

• Such as decimal, base ten (B10), binary, base two (B2), octal, base eight
(B8), and hexadecimal, base sixteen (B16).
1.1 Decimal Number System Representation (B ) 10

• Most people today use decimal representation to count. In the decimal system
there are 10 digits:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9

These digits can represent any value,

for example: 754.


The value is formed by the sum of each digit, multiplied by the base (in this case it
is 10 because there are 10 digits in decimal system) in power of digit position
(counting from zero).

Example of the decimal number system can be seen in this table


1.1.2 Binary Number System Representation (B2)

• Computers are not as smart as humans are (or not yet), it's easy to make an
electronic machine with two states: on and off, or 1 and 0 called binary system.
Binary system uses 2 digits: 0, 1 and thus the base is 2.

• Each digit in a binary number is called a BIT, 4 bits form a NIBBLE, 8 bits form a
BYTE, two bytes form a WORD, and two words form a DOUBLE WORD (rarely
used). Example of binary number system can be seen in the table below.
Binary Number System Representation (B2) Cont’d

Example:
11101 in binary number system has the decimal value as indicated in below:

Hence:
Binary number to decimal conversion; 11011 = 1 + 0 + 4 + 8 + 16 = 29 (base 10).

Note: Your counting must be from right, Least Significant (LSB) Bit to left, Most
Significant Bit (MSB).
Binary Number System Representation (B2) Cont’d

• Another example of converting binary number to decimal number can


be seen in the table below using binary number 10100101.

Hence:
• The binary number 10100101b equals to decimal value of 165 as can be seen in
above.

• There is a convention to add "b" in the end of a binary number, this way we can
determine that 10100101b is a binary number with decimal value of 165.
1.1.3 Octal Number System Representation (B8)

• Octal number system uses 8 values (0, 1, 2, 3, 4, 5, 6, 7) to represent


numbers with 0 having the least value and 7 having the greatest value.

• Octal number system was used extensively in the early mainframe


computer systems but has become less popular in favour of binary and
hexadecimal.

For example:
• The figure, 778 has the first symbol, '7' on the right hand side carrying a
multiplying factor of 80 and the second symbol, '7' from the left hand side
carrying a multiplying factor of 81.

• This figures can then be expressed as:

----------------------------------------778 = 7x81 + 7x80 = 6310


Octal Number System Representation (B8) Cont’d

Another example of octal number system is:

• Using the positional value of each octal digit, we can easily convert octal
integer numbers to decimal.

E.g.: (171)8 = 1 x 82 + 7 x 81 + 1 x 80
= 64 + 56 + 1 = 121
(171)8 = (121)10

 The digits that belong to the octal number system can be easily converted
to the binary system to give the table below:
1.1.4 Hexadecimal Number System Representation (B 16)

• Hexadecimal system uses 16 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C,


D, E, F

• Hexadecimal numbers are compact and easy to read, hence used


often in bigger machines

• It is very easy to convert numbers from binary system to


hexadecimal system and vice-versa; every nibble (4 bits) can be
converted to a hexadecimal digit using the table below:
Hexadecimal Number System Representation (B 16) Cont’d

B10 (Decimal) B2 (Binary) B8 (octal) B16 (Hexadecimal)


0 0000 00 0
1 0001 01 1
2 0010 02 2
3 0011 03 3
4 0100 04 4
5 0101 05 5
6 0110 06 6
7 0111 07 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
  3B2 = 1B8. 1B8 = 3B2. 1B16 = 4B2.
REMARKS 4B2 = 1B16 One digit of Octal One digit of Hex
number is equivalent to number is equivalent to
three digits of Binary four digits of Binary
Hexadecimal Number System Representation (B 16) Cont’d

For example;
• The hexadecimal number 1234h is equal to decimal value of 4660 as can
be seen below.

• There is a convention to add "h" in the end of a hexadecimal number, this


way we can determine that the assigned value is a hexadecimal number.

• "0" (zero) is also added in the beginning of hexadecimal numbers that


begin with a letter (A..F), to avoid ambiguity.
1.1.5 Converting from Decimal System to Any Other
In order to convert from decimal system, to any other system:
• It is required to divide the decimal value by the base of the desired system
• Remember the result and keep the remainder
• Divide process continues until the result is zero
• The remainders are then used to represent a value in that system.

E.g.:
The conversion of the value of 75 (base 10) to Octal System (base 8) can be
seen below:

(75)10 converted to octal will give:


75 ÷ 8 = 9 + 3 Remainder
9÷8=1+1 Remainder
1÷8=0+1 Remainder
Therefore; (75)10 = (113)8
Converting from Decimal System to Any Other Cont’d

Similarly;
The conversion of the value of 39 (base 10) to Hexadecimal System (base 16)
can be seen below:

From the above, the hexadecimal number of 3910 is 27h. All remainders were
below 10 in the above example, so we do not use any letters.
Converting from Decimal System to Any Other Cont’d

A more complex B10 to B16 conversion is Converting decimal number 43868


to hexadecimal form, as can be seen thus:

The result is AB5Ch; where


The resulting binary
the subscript ‘h’ stands for
number is
hexadecimal
1010101101011100b
Converting from Decimal System to Any Other Cont’d

Similarly;
The conversion of the value of 75 (base 10) to Binary System (base 2) can be
seen as follows:

75 converted to binary will give:


75 ÷ 2 = 37 + 1 remainder
37 ÷ 2 = 18 + 1 remainder
18 ÷ 2 = 9 + 0 remainder
9 ÷ 2 = 4 + 1 remainder
4 ÷ 2 = 2 + 0 remainder
2 ÷ 2 = 1 + 0 remainder
1 ÷ 2 = 0 + 1 remainder
Therefore, (75)10 = (1001011)2
1.1.6 COUNTING FROM 0 TO 16 IN BINARY

• Binary numbers must have "b" suffix, example: 00011011b

• Hexadecimal numbers must have "h" suffix, and start with a zero when
first digit is a letter (A.F), example: 0ABCDh
• Octal (base 8) numbers must have "q or o" suffix, example: 77o or 77q.

The table below shows the details

Note:
Intel assembly language accepts both the upper or lower case
letters. Thus it is not case sensitive
COUNTING FROM 0 TO 16 IN BINARY Prefix Notations

In Binary In Decimal In Hex Decimal In Octal


0000 0 0h 0q or o
0001 1 1h 1q
0010 2 2h 2q
0011 3 3h 3q
0100 4 4h 4q
0101 5 5h 5q
0110 6 6h 6q
0111 7 7h 7q
1000 8 8h 10q
1001 9 9h 11q
1010 10 Ah 12q
1011 11 Bh 13q
1100 12 Ch 14q
1101 13 Dh 15q
1110 14 Eh 16q
1111 15 Fh 17q
1.1.7 Logical Unit (LU) of ALU Instructions

The truth table for AND The truth table for OR


Result of Values for B Values for A Result of OR
Values for B Values for A
AND
0 0 0
0 0 0
0 1 1
0 1 0
1 0 1
1 0 0
1 1 1
1 1 1
The result is 1 only if both operands The result is 1 only if, at least one
are 1 operand is 1

The truth table for XOR


Values for B Values for A Result of OR
The result is 1 only if, the operands
0 0 0
have different values, known as
0 1 1 inequality comparator.
1 0 1
1 1 0
1.2 TYPES OF PROGRAMMING LANGUAGES

i. Machine Language (ML):


This requires coding and it comprises series of 0’s and 1’s (binary
number), the only computer understandable language.

Advantages
• The execution of ML is fast. It takes less time to process ML instructions.
• ML uses computer storage more efficiently.

Disadvantages
• It is very difficult to program & debug, i.e. its tedious in writing.
• It is machine dependent i.e. a program in machine language written and
run on a particular machine may not run or may require modification before it
can run on another.
• It is time consuming.
TYPES OF PROGRAMMING LANGUAGES Cont’d

ii Low Level Language (LLL) or Assembly Language


This involves coding instructions using mnemonic codes or symbols

Advantages
• It is more efficient than machine language in terms of being user friendly
• It is more efficient than High level language in the usage of memory
• The use of symbols make it easier to write and learn than ML
• The advent of assembly language made it possible for the writing of system
programs, word processor, spreadsheet and other programs
• Useful in program writing for security compiliers

Disadvantages
• Slower than the machine language program because of the conversion
process involved in translating into machine code or object code before
execution.
• It is also machine dependent
• It consists of a lot of unrelated codes that programmers have to battle with
TYPES OF PROGRAMMING LANGUAGES Cont’d

iii High-Level-Language:
This is English-like in nature and easy to read, write and understand by
human.
Examples are; BASIC, COBOL, FORTAN, JAVA, C, C++, PASCAL, APL,
LISP, PROLOG etc

Advantages
• Closer to user than other forms of programming languages
• The easiest level of programming language to be understood.
• It provides a good methodology for writing sophisticated programs.
• Compilers are easy to get
• Program development is faster, portable and easier to maintain

Disadvantages
• It takes longer time to execute. i.e.; it is not as fast as ML & LLL (i.e.
computer memory is not efficiently used when compared to ML and LLL).
User's view of a computer system
DIFFERENT TYPES OF ENCODING

i. American Standard Code for Information Interchange


(ASCII) coding system: 27=128 (128 bit of information
hidden + 128 bit visual) = 256bit of information 28 = 256
bit information

ii Binary Coded Decimal (BCD)

iii Extended Binary Coded Decimal Interchange Code


( EBCDIC) Coding System
Different Types Of Encoding Cont’d

1. American Standard Code for Information Interchange (ASCII) coding system


Different Types Of Encoding Cont’d

American Standard Code for Information Interchange (ASCII) coding system:


• This is the most widely used alphanumeric code system
• It is used in most micro computers and mini computers and in many
mainframes.
• The ASCII code is a seven bit code; it has 27=128 possible code groups.
• In the 7 bits code, the first 3 bits represent the zone bits and the last 4 bits
represent the numeric bits.

Summary of ASCII code system is shown below:

Characters Zone bits Numeric bits


0-9 011 0000-1001
A-O 100 0001-1111
P-Z 101 0000-1010
a-o 110 0001-1111
p-z 111 0000-1010

See the text book for detailed ASCII code system table
Different Types Of Encoding Cont’d

Examples:
Question: Represent the string character Sam in binary format

Answer: Since Sam contains an alphabet, the ASCII representation is


suitable for this conversion

S = 101 0011
a = 110 0001
m = 110 1101

Answer: 101001111000011101101b

Sam = 53H 61H 6DH === 53616DH

Study more examples from the text book


Different Types of Encoding Cont’d

ii Binary Coded Decimal (BCD)


• Only four bits binary numbers from 0000 through 1001 are used for
binary coded decimal. The BCD code does not use the numbers 10, 11,
12, 13, 14, 15

• BCD number is not the same as binary number

Example:

13710 to straight binary coding is 10001001b

While;
13710 to BCD is 0001 0011 0111

Question: Why is BCD not often used in modern high speed digital system ?
(See answer in the text book)
Different Types of Encoding Cont’d

iii Extended Binary Coded Decimal Interchange Code ( EBCDIC) Coding


System

• Eight bits are used to represent each character i.e. 28 = 256


characters can be represented

• IBM minicomputers and mainframe computers use the EBCDIC

• The eight bits can be divided into two; the zone bits and the
numeric bits

Refer to text book for detailed table


MODES OF DATA REPRESENTATION

i. Signed - Magnitude Numbers:

• The sign bit for positive is represented by 0 and the sign bit for negative
is represented by 1.

• Sign-magnitude has drawbacks of two different zeros and much more


complicates hardware for performing addition, subtraction, and any
binary integer operations other than complement.

• Not good for computer (slow).

Thus, in a word of 4 bytes (32 bits), numbers can be represented as follows:

Positive (0) Negative (1)


+5 = 0101; -5 = 1101
+3 = 0011; -3 = 1011
+7 = 0111; -7 = 1111
Modes of Data Representation Cont’d

Example:
Question: Convert -52 to binary using an 8 bits machine

Answer:
• The binary equivalence of 52 is 110100
• This makes a total of 6bits
• But since we are working on an eight bit machine,
• We have to pad the numbers with 0’s so as to make it a total
of 8bits
• In this case, the sign bit has to come first and the padded 0
follows
• Thus the binary equivalence of -52 is 10110100.
Modes of Data Representation Cont’d

ii One’s complement:
• Positive numbers are represented in the “normal” manner (same as unsigned
integers with a zero sign bit)
• Negative numbers are represented by complementing all of the bits of the
absolute value of the number. Numbers are negated by complementing all bits
• The 1’s complement form of any binary number is simply by changing each 0 in
the number to a 1 and vice versa.

• This mode still has a drawback as far as computer is concerned


(see text)
Example:
Question: Find the 1’s complement of -7

Answer: -7 in the actual representation without considering the machine


bit is 1111. To change this to 1’s complement, the sign bit has to be retained and
other bits have to be inverted. Thus, the answer is: 1000. 1 denotes the sign
bit.
Modes of Data Representation Cont’d

iii Two’s Complement Mode:


• Positive numbers are represented in the “normal” manner (same as
unsigned integers with a zero sign bit)

• Negative numbers are represented by complementing all of the bits of


the absolute value of the number and adding one.

• Another way is by examining all the bits from right (LSB) to left (MSB)
and complementing all the bits after the first ‘1’ is encountered.

• Two’s complement is used in just about every binary computer ever


made

• The advantage of 2’s complement is that it allows us to perform the


operation of subtraction by actually performing addition in signed values
10 – 12 == 1010 – 1100
0100 + 1010
1010
1110 = = 0010 -2

12 – 10 = = 1100 -1010
0110
+1100
10010 === +2
Modes of Data Representation Cont’d

Examples:
Question: Convert -52 to its 2’s complement
Answer: The 1’s complement of -52 is 11001011
To convert this to 2’s complement we have to add 1
11001011
+1
11001100

Another Example adding singed and unsigned values together


Question: Add -9 and +4 using 5-bit
The 2’s complement of -9 is 10111
The sign magnitude of +4 is 00100
This gives;
10111
+ 00100
11011

The sum has a sign bit of 1 indicating a negative number


Memory Structures in a Computer

In most modern computer systems, individual storage elements are


organized into different groups:

• Bits: Memory consists of bits (0 or 1). A single binary digit is called a “bit”. All
information in a digital system is represented by a sequence of bits.
• Nibble: Collection of 4 related bits.
• Bytes (8 bits): An 8-bit sequence is called a “byte”. A simple byte can represent
256 = (28) pieces of information
• Word (16 bit or 2bytes): A word is the largest number of bits the computer
can handle in a single operation. A 16-bit sequence is a “word”.

E.g.:
Bit 12
Nibble 10102
Byte 101001012
Word 10100101111100002
End of Module Assessments (EMA) Multiple Choice Questions

1. American Standard Code for Information Interchange uses how many bit(s) per
character?
(a) 2 (b) 4 (c) 1 (d) 8
2. The decimal number 1772 corresponds to what Hexadecimal number?
(a) 6FC (b) 6EC (c) EC6 (d) 6CE
3. Why is two’s complement mode of data representation very important in
computers?
(a) Because it is used effectively for addition of unsigned values
(b) Because it can represents any data in computers
(c) Because it allows the operation of subtraction by actually
performing addition in signed values
(d) Because it is the modern way of representing data in computer
4. A byte can represent what pieces of information?
(a) 256(b) 258 (c) 128 (d) 512

5. What ASCII character string can you derive from this machine language code
1001000100010110011001010000 ?
(a) HELO (b) SAVE (c ) HELP (d) SAFE
End of Module Assessments (EMA) Essay Questions

6. Fill in the blank cells of the table below with the correct numeric format. For cells
representing binary values, only 8-bit values are allowed! If a value for a cell is
invalid or cannot be represented in that format, write "X".

7. List two drawbacks using Low Level Language

8. Why is the Binary number system useful in electronic data processing?

9. A 16-bit sequence is a what?

10.Convert +10 to binary number on a 4-bit machine using sign magnitude notation

You might also like