m5zn_d45f00ca48164aa

Download Report

Transcript m5zn_d45f00ca48164aa

Number systems, Operations, and Codes
1- Decimal Numbers
The decimal number system has ten digits .
These are : 0 , 1 , 2 , 3, 4 , 5 , 6 , 7 , 8 , 9 .
The decimal number
system has the base = 10
Example -1-
Example -2-
Example -3- : Express the decimal number 897.9 as a sum of the value
of each digit.
1
2- Binary Numbers
The binary number system has two digits (bits) .
These are : 0 , 1.
The binary number system
has the base = 2
The weight of a bit
increases from right to left
in a binary whole number
2
Decimal to Binary Conversion
Method : To get the binary number for a given decimal number ,
divide decimal number by 2 until the quotient is 0 .
Remainders form the binary number .
Example -1-
Example -2- :
convert the
following decimal
numbers into
binary :
19
-
45
3
Binary to Decimal Conversion
Method : Add the weights of all “1”s in a binary number to get
the decimal values
Example -1-
Example -2-
Example -3- : convert the following binary numbers
10101110 , 11.011101 into decimal number ?
4
Convert Decimal Fraction to binary
Method : Repeated multiplication by 2 until fractional part is zero
Example -1-
Example -2- : convert the following decimal numbers into binary :
0.375
0.559
5
3- Octal Numbers
The Octal number system has 8 digits.
These are : 0 , 1, 2 , 3, 4 , 5 , 6, 7
The Octal system has the base = 8
Assignment:
1. How could we convert Octal to decimal ? give an example .
2. How could we convert Decimal to Octal ? give an example .
3. How could we convert Binary to Octal ? give an example .
4. How could we convert Octal to Binary ? give an example .
6
Convert Decimal to Octal

Divide the given decimal number by base 8 and write the
reminders starting first reminder from right to left
Example: (57)10 = (?)8
Answer: (71)8
Or using polynomial of weights, like: … 83 82 81 80
512 64 8 1
Example: (413)10 =
0 6
3 5
Where: (635)8 = 5.80 + 3.81 + 6.82 =
5.1 + 3.8 + 6.64 = 5 + 24 + 384 =
(413)10
7
4- Hexadecimal Numbers
The hexadecimal number system has 16 digits.
These are : 0 , 1, 2 , 3, 4 , 5 , 6, 7 , 8 , 9, A , B , C , D , E , F
The hexadecimal system has
the base = 16
8
Convert Decimal to Hexadecimal

Divide the given decimal number by base 16 and write
the reminders starting first reminder from right to left
Example: (57)10 = (?)16
Answer: (39)16
Or using polynomial of weights, like: … 162 161 160
256 16
1
Example: (413)10 =
1
9
D
Where: (19D)16 = D.160 + 9.161 + 1.162 =
13.1 + 9.16 + 1.256 =
(413)10
9
Convert between different Number systems



Base of binary system is 2 = 21
Base of Octal System is 8 = 23
Base of Hexadecimal system is 16 = 24

It means each Hexadecimal digit ~
4 binary digits, and each Octal digit ~
3 binary digits
Examples: Convert the binary value 110011000101100
To the corresponding Octal and hexadecimal value
110 011 000 101 100 = 63054 Octal
110 0110 0010 1100 = 662C Hexadecimal!
10
Hexadecimal Numbers (cont.)
Binary to hexadecimal
Method:
•
Break the binary number into 4-bit groups starting at the rightmost bit , Then:
•
Replace each 4-bit group with the equivalent hexadecimal symbol.
11
Hexadecimal Numbers (cont.)
hexadecimal to Binary
Method :
Replace each hexadecimal symbol with the appropriate four bits.
12
Hexadecimal Numbers (cont.)
hexadecimal to Decimal
Method
Convert the hexadecimal to binary then convert from binary to decimal.
13
Hexadecimal Numbers (cont.)
Decimal to hexadecimal
Method :
Repeated division of a decimal number by 16 .
14
Arithmetic Operations
1st and 2nd Complement
1st complement :
Method : Invert each bit to get the 1st complement
Example -1-
Example -2- : Determine the first complement of the following binary
00011010
-
11110111 - 10001101
2nd complement :
Method -1- :
2nd complement = 1st complement
+
1
Example -115
Arithmetic Operations
1st and 2nd Complement (cont.)
2nd complement (cont.) :
Method -2- : Change all
the bits to the left of the
least significant 1 to gets
the 2nd complement
Example -1- : Determine the 2nd complement of the following binary
00010110
- 11111100
-
10010001
Application
Example
16