Module 2 Number System and Data Representation
Module 2 Number System and Data Representation
COMPUTER
FUNDAMENTALS AND
PROGRAMMING
NUMBER SYSTEMS AND
DATA REPRESENTATION
INTRODUCTION
The 0s and 1s used to represent digital data are referred to as binary digits
— from this term we get the word bit that stands for binary digit. A bit is a 0
or 1 used in the digital representation of data.
BITS AND BYTES
data.
Bit One binary digit Gigabit 230 bits
Byte 8 bits Gigabyte 230 bytes
Kilobit 1,024 bits Terabyte 240 bytes
Kilobyte 1,024 bytes Petabyte 250 bytes
Megabit 1,048,576 bits Exabyte 260 bytes
Megabyte 1,048,576 bytes
BITS AND BYTES
• Bits is use for data rates such as internet connection speeds, or movie
download speed.
Example:
• 104KB - read as 104 Kilobyte (KB or KByte), is often used when referring to the size
of a small computer files.
• 56Kbps - read as 56 Kilobits per second (Kb or Kbit), is often used for slow data
rates. Such as 56Kbps dial-up connection.
• 16GB - read as 16 Gigabyte (GB or GByte), is commonly used to refer to storage
capacity. Such as 16GB of Flash Drive.
• 100Gbit - read as 100 Gigabit (Gb or Gbit), is used for really fast network speeds.
NUMBER SYSTEM
• The decimal number system uses ten digits: 0,1,2,3,4,5,6,7,8 and 9 with the base
or radix of 10. The decimal number system is the system that we generally use to
represent numbers in real life. If any number is represented without a base, it
means that its base is 10.
• Any positive integer N, represented in the decimal system as a string of decimal
digits, may also be expressed as a sum of powers of 10, with each power
weighted by a digit.
DECIMAL NUMBER SYSTEM
• Binary has only two values: 0 and 1. The base or radix of this number system is 2.
Digits 0 and 1 are called bits and 8 bits together make a byte. The data in
computers is stored in terms of bits and bytes. The binary number system does not
deal with other numbers such as 2,3,4,5 and so on.
• The place values in the binary system are the powers of the base b=2, just as the
place values in the decimal systems are the powers of ten. Specifically, the place
values of the integral part of a binary number are the non-negative powers of two:
OCTAL NUMBER SYSTEM
• The base or radix of this number system is 16. The symbols used are 0, 1, 2, 3, 4, 5, 6,
7, 8, 9 and 10 to 15 are written as A, B, C, D, E, F respectively. Since 16 = 24 , each
hexadecimal digit has a unique 4-bit binary representation.
NUMBER SYSTEM CONVERSION
❖ BINARY TO DECIMAL
• Any binary number can be written in expanded notation as the sum of each digit
times that digit's place value.
• Since each power of two is weighted by either 0 or 1, the binary number is simply
the sum of those place values in which the bit 1 appears. This sum at once gives us
the decimal equivalent of the binary number.
❖ DECIMAL TO BINARY
• To convert decimal number to its binary equivalent, we use succesive division.
Divide each succesive quotient by 2, noting the remainders, and stop until we
reach a quotient of 0. The sequence of remainders from the bottom to up, as
indicated by the arrow, yields the required binary equivalent.
❖ BINARY TO OCTAL
• To convert a binary number to octal, we partition the binary number into groups of
three bits, start from the ones digit and proceed to the left. If the number of bits is
less than 3 in the last group, we add zeros to the left.
❖ OCTAL TO BINARY
• To convert an octal number to binary, we write 3 bit binary equivalent to each
octal digit in the same order.
Solution;
NUMBER SYSTEM CONVERSION
❖ BINARY TO HEXADECIMAL
• To convert a binary number to hexadecimal, we partition the binary number into
groups of four bits, start from the ones digit and proceed to the left. If the number of
bits is less than 4 in the last group, we add zeros to the left.
❖ HEXADECIMAL TO BINARY
• To convert an Hexadecimal number to binary, we write 4 bit binary equivalent to
each hexadecimal digit in the same order.
❖ DECIMAL TO OCTAL
• To convert a given decimal integer number to octal, successively divide the given
number by 8 till the quotient is 0, noting the remainders. The sequence of
remainders from the bottom to up, as indicated by the arrow, yields the required
octal equivalent.
For example: convert (378)10 into octal.
Solution;
NUMBER SYSTEM CONVERSION
❖ OCTAL TO DECIMAL
• For conversion octal to decimal number, multiply each digit in the octal number by
the weight of its position and add all the product terms.
❖ DECIMAL TO HEXADECIMAL
• To convert a given decimal number to hexadecimal, successively divide the given
number by 16 till the quotient is 0, noting the remainders. The sequence of
remainders from the bottom to up, as indicated by the arrow, yields the required
hexadecimal equivalent
❖ OCTAL TO HEXADECIMAL
• For conversion of octal to Hexadecimal, first convert the given octal number to
binary and then binary number to hexadecimal.
For example: convert (756)8 into hexadecimal.
Solution;
NUMBER SYSTEM CONVERSION
❖ HEXADECIMAL TO OCTAL
• For conversion of hexadecimal to octal, first convert the given hexadecimal
number to binary and then binary number to octal.
For example: convert s (1EE)16 into OCTAL.
Solution;
BINARY ARITHMETIC
❖ BINARY ADDITION
BINARY ARITHMETIC
❖ BINARY SUBTRACTION
• For subtraction in the decimal system, normally the borrow method is used.
BINARY ARITHMETIC
❖ BINARY MULTIPLICATION
• Binary multiplication uses the same techniques as decimal multiplication. In fact,
binary multiplication is much easier because each multiplying digit is either zero or
one.
RULES:
When performing binary multiplication, remember the following rules;
1. Copy the multiplicand when the multiplier digit is 1. Otherwise, write a row of zeros.
2. Shift the results one column to the left for a new multiplier digit.
3. Add the results using binary addition to find the product.
BINARY ARITHMETIC
❖ BINARY DIVISION
• Division of binary numbers uses the same technique as division in
the decimal system.
RULES
When doing binary division, some important rules need to be remembered;
1. When the remainder is greater than or equal to the divisor, write a 1 in the
quotient and subtract.
2. When the remainder is less than the divisor, write a 0 in the quotient and
add another digit from the dividend.
3. If all the digits of the dividend have been considered and there is still a
remainder, mark a radix point in the dividend and append a zero.
Nothing is impossible. The
word itself says ‘I’m possible!'
— Audrey Hepburn