Download Number Systems - Computing System - Lecture Slides and more Slides Computer Science in PDF only on Docsity!
Number Systems
CT101 – Computing Systems
Overview
- Know the different types of numbers
- Describe positional notation
- Convert numbers in other bases to base 10
- Convert base 10 numbers into numbers of other bases
- Describe the relationship between bases 2, 8, and 16
- Fractions
- Negative Numbers Representation
- Floating Point Numbers Representation
Number Systems …
- The base of number system represents the number of digits that are used in the system. The digits always begin with 0 and continue through one less than the base
- Examples:
- There are two digits in base two (0 and 1)
- There are eight digits in base 8 (0 through 7)
- There are 10 digits in base 10 (0 through 9)
- The base determines also what the position of the digits mean Docsity.com
Positional Notation
- It is a system of expressing numbers in which the digits are arranged in succession and, the position of each digit has a place value and the number is equal to the sum of the products of each digit by its place value
- Example:
- Consider the number 954:
- 9 * 10 2 + 5 * 10 1 + 4 * 10 0 = 954
- Polynomial representation - formal way of representing numbers, where X is the baseof the number:
- 9 * X 2 + 5 * X 1 + 4 * X 0
- Formal representation – consider that the base of representation is B and the number has n digits, where d (^) i represents the digit in the ith position. - d (^) n * Bn-1^ + d (^) n-1 * Bn-2^ + …+ d 2 B +d (^1) - 642 is: 6 3 * 10 2 + 4 2 * 10 + 2 1 * 10 0
Binary, Octal and Hexadecimal
- Decimal base has 10 digits (0, 1, 2, 3, 4, 5, 6, 7, 8,
- Binary is base 2 and has two digits (0 and 1)
- Octal is base 8 and has 8 digits (0, 1, 2, 3, 4, 5, 6,
- Hexadecimal is base 16 and has 16 digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F)
Converting Octal to Decimal
- What is the decimal equivalent of octal number 642?
**6 x 8² = 6 x 64 = 384
- 4 x 8¹ = 4 x 8 = 32
- 2 x 8º = 2 x 1 = 2 = 418 in base 10**
- Remember that octal base has only 8 digits (0, 1, 2, 3, 4, 5, 6, 7)
Converting Binary to Decimal
- Remember that binary base has only 2 digits (0, 1)
1 x 2^4 **= 1 x 16 = 16
- 0 x 2**^3 **= 0 x 8 = 0
- 1 x 2**^2 **= 1 x 4 = 4
- 1 x 2**^1 **= 1 x 2 = 2
- 0 x 2**^0 = 0 x 1 = 0 = 22 in base 10
- What is the equivalent decimal of the binary 10110 number?
Review Question 1
What is octal number 11 in decimal representation?
A. 7
B. 8
C. 9
D. I don’t know …
Review Question 3
What is decimal representation of hexadecimal number FF?
A. 10
B. 255
C. 256
D. I don’t know …
Arithmetic in Binary
- The rules of arithmetic are analogous in other basis as in decimal base Addition 1 1 0 0
1 0 1 0 10 1 1 0
Should read 1+1=0 with a carryof 1 similar to base 10 where 9 + 1 = 0 with a carry of 1 = 10
Subtraction 1 1 0 0
1 0 1 0 0 1 11 0
-1 can be stated as 1 with aborrow of 1. Leading 1 we consider to be the sign, so 11 means -
Subtracting in Binary
- The rules of the decimal base applies to binary as well. To be able to calculus 0-1, we have to “borrow one” from the next left digit.
- More precisely, we have to borrow one power of the base
- You can check if the result is correct by converting the operands in decimal and making the calculus.
1 2 0 2 0 2 1 0 1 0
- 0 1 1 1 0 0 1 1
Review Question 4
- Add 4 bit number 0100 with 0111. The answer is:
A. 1001
B. 1011
C. 1110
D. I don’t know …
Power of two Number Systems
- Binary and octal numbers have a very special relation between them: given a binary number, can be read in octal and given an octal number can be read in binary (i.e. have 753 in octal, in binary you have 111 101 011 by replacing each digit by its binary representation)
- Table represents counting in binary with octal and decimal representation
Binary Octal Decimal 000 0 0 001 1 1 010 2 2 011 3 3 100 4 4 101 5 5 110 6 6 111 7 7 1000 10 8 1001 11 9 1010 12 10
Converting Binary to Octal
- Start at the rightmost binary digit and mark the digits in groups of three
- Convert each group individually
10101011 10 101 011 2 5 3 10101011 is 253 in base 8
- The reason that binary can be immediately converted in octal and vice-versa is because 8 is power of 2
- There is a similar relationship between binary and hexadecimal