This document provides an introduction to digital number systems used in computer science. It discusses binary, decimal, octal, and hexadecimal number systems. For each system, it explains the base, digits used, and how to convert between the number systems and decimal. It also covers signed binary number representations, binary arithmetic, detecting overflow, and binary coded decimal. References are provided at the end for additional reading on number systems and computer data representation.
THE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptx
Introduction to Digital Number Systems and Computer Data Representation
1. INTRODUCTION TO COMPUTER
SYSTEM
CSC 2313
LECTURE 3
Department of Maths and Computer-Science
Faculty of Natural andApplied Science
BY
UMAR DANJUMA MAIWADA
3. INTRODUCTION
It is the base of a system.
A value of each digit in a number can be determined
using the digit, the number’s position etc
3
4. DIGITAL NUMBER SYSTEM
It can understand positional number system only where there
are a few symbols called digits and these symbols represent
different values depending on the position they occupy in the
number.
4
5. BINARY NUMBER SYSTEM
It is a number expressed in base two
It represent a numeric value using two different symbols: 0 and
1
Each digit is referred to as a bit
0001 numeric value 20
0010 numeric value 21
0100 numeric value 22
1000 numeric value 23
5
6. 6
2 24
2 12 R 0
2 6 R 0
2 3 R 0
2 1 R 1
0 R 1
= 110002
Example
Decimal Number = 24
Equivalent binary
8. DECIMAL NUMBER SYSTEM
It employs 10 as the base
It requires 10 different numerals
It is called Denary
8
9. 9
Example
1234
(1x1000) + (2x100) + (3x10) + (4xl)
(1x103) + (2x102) + (3x101) + (4×100)
1000 + 200 + 30 + 4
1234
Each position represents a specific power of the base (10).
For example, the decimal number 1234 consists of the
digit 4 in the units position, 3 in the tens position, 2 in
the hundreds position, and 1 in the thousands position
14. HEXADECIMAL NUMBER SYSTEM
Uses 10 digits and 6 letters, 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
Base 16
They are used by designers and programmers
Each hexadecimal digit represent four binary digits
Also called base 16 number system
14
18. Number System Conversion
This section discusses techniques to convert one number system to another
number system.There are many methods or techniques which can
be used to convert numbers from one base to another.We'll
demonstrate here the following:
Decimal to Other Base System
Other Base System to Decimal
Other Base System to Non-Decimal
Shortcut method - Binary to Octal
Shortcut method - Octal to Binary
Shortcut method - Binary to Hexadecimal
Shortcut method - Hexadecimal to Binary 18
19. BASE 10 TO BASE N CONVERSION
Steps
Step 1 - Divide the decimal number to be converted by the value of the
new base.
Step 2 - Get the remainder from Step 1 as the rightmost digit (least
significant digit) of new base number.
Step 3 - Divide the quotient of the previous divide by the new base.
Step 4 - Record the remainder from Step 3 as the next digit (to the left) of
the new base
number.
Repeat Steps 3 and 4, getting remainders from right to left, until the
quotient becomes zero in
Step 3.
The last remainder thus obtained will be the most significant digit (MSD) of
the new base
number.
19
20. SIGNED BINARY NUMBER CONVENTIONS
Signed Binary Number Representations (3 methods)
Signed Magnitude (SM)
Easiest for people to read (Not used by computers)
Here is an example of Signed Magnitude number with 4-bit
word size
20
Binary SM numbers for n-bit word ranges from +(2 – 1) to - (2 – 1)
22. DIMINISHED RADIX COMPLEMENT (DRC) OR 1’S COMPLEMENT
SOME COMPUTER SYSTEMS USE THIS INFORMATION BECAUSE IT IS EASIER TO CONVERT.
TO OBTAIN A NEGATIVE DRC OR 1’S COMPLEMENT:
WRITE A POSITIVE NUMBER WITH MSB SET TO 0 (POSITIVE SIGN)
NEGATE (INVERT) EVERY BIT INCLUDING SIGN BIT TO OBTAIN THE NEGATIVE
NUMBER.
HERE IS AN EXAMPLE OF 4-BIT WORD SIZE:
22
DRC numbers for n-bit word ranges from +(2n-1 – 1) to –(2n-1– 1)
24. RADIX COMPLEMENT (RC) OR 2’S COMPLEMENT
MAJORITY OF DIGITAL SYSTEMS USE RC SINCE IT
SIMPLIFIES THE BINARY ARITHMETIC OPERATION.
TO OBTAIN A NEGATIVE RC OR 2’S COMPLEMENT:
WRITE A POSITIVE NUMBER WITH THE MSB SET TO 0
(POSITIVE SIGN)
NEGATE (INVERT) EVERY BIT INCLUDING SIGN BIT
ADD A 1 TO THE RESULT TO OBTAIN THE NEGATIVE NUMBER
25. BINARY ARITHMETIC
+7 _ 0 1 1 1
+(-2) _ 1 1 1 0
----------
0 1 0 1 “Ignore the left-most carry, and the result is +5”
Addition of Unsigned Binary Numbers
Unsigned addition Signed works exactly the same way as singed addition, allowing us to
use the same circuitry.
+7 _ 0 1 1 1
+3 _ 0 0 1 1
----------
1 0 1 0 “Result is +10. If there is a carry beyond the available bits, then an
overflow has occurred.
25
26. FIXED PRECISION AND OVERFLOW.
computer systems, this isn’t the case. Numbers in computers are
typically represented using a fixed number of bits.These sizes are
typically 8 bits, 16 bits, 32 bits, 64 bits and 80 bits.These sizes are
generally a multiple of 8, as most computer memories are organized
on an 8 bit byte basis.
Numbers in which a specific number of bits are used to represent the
value are called fixed precision numbers.When a specific number of
bits are used to represent a number, that determines the range of
possible values that can be represented.
For example, there are 256 possible combinations of 8 bits, therefore
an 8 bit number can represent 256 distinct numeric values and the
range is typically considered to be 0-255.Any number larger than
255 can’t be represented using 8 bits. Similarly, 16 bits allows a range
of 0-65535.
26
27. SIGNED AND UNSIGNED NUMBERS
we have only considered positive values for binary numbers.When a
fixed precision binary number is used to hold only positive values, it is
said to be unsigned. In this case, the range of positive values that can be
represented is 0 -- 2n-1, where n is the number of bits used. It is also
possible to represent signed (negative as well as positive) numbers in
binary. In this case, part of the total range of values is used to
represent positive values, and the rest of the range is used to represent
negative values.
There are several ways that signed numbers can be represented in
binary, but the most common representation used today is called two’s
complement.The term two’s complement is somewhat ambiguous, in
that it is used in two different ways. First, as a representation, two’s
complement is a way of interpreting and assigning meaning to a bit
pattern contained in a fixed precision binary quantity.
27
28. DETECTING OVERFLOW
Unsigned number addition
If the addition has a carry beyond the available bits then an overflow
has occurred.
Signed (RC, 2’s complement) number addition
If the operands have different signs, then overflow cannot
occur, since one number is
being subtracted from the other.
If the operands have the same sign and the result has a
different sign, then an overflow has occurred.A quick way
to identify an overflow situation is when the carry into the
sign-bit position and the carry out of sign-bit position are
different. 28
29. 29
Binary coded decimal (BCD)
BCD assigns 4 binary bits to each binary digit. The only drawback is that only 0 to 9 are used,
and the other 6 combinations from 10 to 15 are not used.
BCD Digits
0 ................ 0000
1 ................ 0001
2 ................ 0010
3 ................ 0011
4 ................ 0100
5 ................ 0101
6 ................ 0110
7 ................ 0111
8 ................ 1000
9 ................ 1001
31. REFERENCES
Number Systems, Base Conversions, and Computer Data
Representation
An introduction to binary, hexadecimal and octal
Computer Number system tutorials point
31