1.0 Numbering Systems
1.0 Numbering Systems
0 Numbering Systems
• But when dealing with a computer at the machine level, we must be more
concerned with how data are stored.
• 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
• 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
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)
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.
• 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)
For example;
• The hexadecimal number 1234h is equal to decimal value of 4660 as can
be seen below.
E.g.:
The conversion of the value of 75 (base 10) to Octal System (base 8) can be
seen below:
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
Similarly;
The conversion of the value of 75 (base 10) to Binary System (base 2) can be
seen as follows:
• 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.
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
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
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
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
S = 101 0011
a = 110 0001
m = 110 1101
Answer: 101001111000011101101b
Example:
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
• The eight bits can be divided into two; the zone bits and the
numeric bits
• The sign bit for positive is represented by 0 and the sign bit for negative
is represented by 1.
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.
• 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.
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
• 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".
10.Convert +10 to binary number on a 4-bit machine using sign magnitude notation