Download presentation
Presentation is loading. Please wait.
Published byCecil Griffin Modified over 8 years ago
1
Number Systems
2
ASCII – American Standard Code for Information Interchange – Standard encoding scheme used to represent characters in binary format on computers – 7-bit encoding, so 128 characters can be represented – 0 to 31 (& 127) are "control characters" (cannot print) Character Representation
3
Decimal, hex & character representations are easier for humans to understand; however… All the data in the computer is binary An int is typically 32 binary digits – int y = 5; (y = 0x00000005;) In computer y = 00000000 00000000 00000000 00000101 A char is typically 8 binary digits – char x = 5; (or char x = 0x05;) In computer, x = 00000101 Binary Data
4
Computer systems are constructed of digital electronics. That means that their electronic circuits can exist in only one of two states: on or off. Most computer electronics use voltage levels to indicate their present state. For example, a transistor with five volts would be considered "on", while a transistor with no voltage would be considered "off.” These patterns of "on" and "off" stored inside the computer are used to encode numbers using the binary number system. Because of their digital nature, a computer's electronics can easily manipulate numbers stored in binary by treating 1 as "on" and 0 as "off.” How Computers Store Numbers
5
A number system defines how a number can be represented using distinct symbols. A number can be represented differently in different systems. For example, the two numbers (2A) 16 and (52) 8 both refer to the same quantity, (42) 10, but their representations are different. Number System
6
S = {0, 1, 2, 3, 4, 5, 6, 7} Common Number Systems SystemBaseSymbols Used by humans? Used in computers? Decimal100, 1, … 9YesNo Binary20, 1NoYes Octal80, 1, … 7No Hexa- decimal 160, 1, … 9, A, B, … F No
7
The word decimal is derived from the Latin root decem (ten). In this system the base b = 10 and we use ten symbols: The symbols in this system are often referred to as decimal digits or just digits. Decimal S = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
8
The word binary is derived from the Latin root bini (or two by two). In this system the base b = 2 and we use only two symbols: The symbols in this system are often referred to as binary digits or bits (binary digit). Binary S = {0, 1}
9
The word hexadecimal is derived from the Greek root hex (six) and the Latin root decem (ten). In this system the base b = 16 and we use sixteen symbols to represent a number. The set of symbols is: Note that the symbols A, B, C, D, E, F are equivalent to 10, 11, 12, 13, 14, and 15 respectively. The symbols in this system are often referred to as hexadecimal digits. Each hexadecimal digit represents four binary digits (bits), and the primary use of hexadecimal notation is a human-friendly representation of binary-coded values in computing and digital electronics. Hexadecimal S = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F}
10
The word octal is derived from the Latin root octo (eight). In this system the base b = 8 and we use eight symbols to represent a number. The set of symbols is: Each octal digit represents three binary digits (bits) Octal S = {0, 1, 2, 3, 4, 5, 6, 7}
11
Types of Number System
13
Conversion Among Bases DecimalOctal Binary Hexadecimal The possibilities:
14
Quick Example 25 10 = 11001 2 = 31 8 = 19 16 Base
15
Binary to Decimal DecimalOctal Binary Hexadecimal
16
Technique Multiply each bit by 2 n, where n is the “power” of the bit The power is the position of the bit, starting from 0 on the right ADD the results Binary to Decimal 101011 2 => 1 x 2 0 = 1 1 x 2 1 = 2 0 x 2 2 = 0 1 x 2 3 = 8 0 x 2 4 = 0 1 x 2 5 = 32 43 10 Example Bit 0
17
Technique Multiply each bit by 2 n, where n is the “power” of the bit The power is the position of the bit, starting from 0 on the right ADD the results FRACTIONS Binary to Decimal 10.0110 2 => 1 0. 0 1 1 0 Example 2 -4 2 -3 2 -2 2 -1 2020 2121 Bit 0 0 x (1/16) = 0 1 x (1/8) = 1/8 1 x (1/4) = 1/4 0 x (1/2) = 0 0 x (1) = 0 1 x (2) = 2 2 -4 2 -3 2 -2 2 -1 2020 2121 Ans: 2.375
18
Octal to Decimal DecimalOctal Binary Hexadecimal
19
Technique Multiply each bit by 8 n, where n is the “power” of the bit The power is the position of the bit, starting from 0 on the right Add the results Octal to Decimal Example Bit 0 724 8 => 4 x 8 0 = 4 2 x 8 1 = 16 7 x 8 2 = 448 468 10
20
Hexadecimal to Decimal DecimalOctal Binary Hexadecimal
21
Technique Multiply each bit by 16 n, where n is the “power” of the bit The power is the position of the bit, starting from 0 on the right Add the results Hexadecimal to Decimal Example ABC 16 => C x 16 0 = 12 x 1 = 12 B x 16 1 = 11 x 16 = 176 A x 16 2 = 10 x 256 = 2560 2748 10
22
Decimal to Binary DecimalOctal Binary Hexadecimal
23
Technique Divide by the base 2, keep track of the remainder Keep dividing until the quotient is 0. Take the remainder from the bottom and move upwards as the answer Decimal to Binary E.g.: Convert 125 10 to binary Take the remainder from bottom upwards as answer Ans: 1111101 2
24
Technique For the numbers after the point, multiply it by 2 From the answer, take again the fraction part and multiply it by 2 again Keep on multiplying the fraction by 2 until the fraction part is 0 FRACTIONS Decimal to Binary E.g.: Convert 12.25 10 to binary Ans: 1100.01 2 12 / 2 = 6 6 / 2 = 3 3 / 2 = 1 1 / 2 = 0 R0 R1 0.25 X 2 = 0.50 0.50 X 2 = 1.00 12. 25 01 1100
25
3.14579.14579 x 2 0.29158 x 2 0.58316 x 2 1.16632 x 2 0.33264 x 2 0.66528 x 2 1.33056 etc. 11.001001... FRACTIONS Decimal to Binary
26
Octal to Binary DecimalOctal Binary Hexadecimal
27
Technique Convert each octal digit to a 3-bit equivalent binary representation 1 octal digit = 3 binary digits Octal to Binary E.g.: Convert 705 8 to binary 7 0 5 111 000 101 Start from the right ‘0’ bit 4 2 1 Ans: 111 000 101 2
28
Binary to Octal DecimalOctal Binary Hexadecimal
29
Technique Divide the binary bits in group of 3’s, starting from the RIGHT Add 0’s to the last group to make it 3 bits Convert each grouped binary to their octal digits Binary to Octal E.g.: 1011010111 2 001 011 010 111 1 3 2 7 Start from the right ‘0’ bit 4 2 1 Ans: 1327 8 4 2 1 001 011 010 111 Divide the binary numbers into groups of 3’s. Add ‘0’ to the last group to make it 3 bits
30
Hexadecimal to Binary DecimalOctal Binary Hexadecimal
31
Technique Convert each hexadecimal digit to a 4-bit equivalent binary representation 1 hexadecimal digit = 4 binary digits Hexadecimal to Binary E.g.: Convert 3A8 16 to binary 3 A (10) 5 0011 1010 0101 Start from the right ‘0’ bit 8 4 2 1 Ans: 0011 1010 0101 2 8 4 2 1
32
Binary to Hexadecimal DecimalOctal Binary Hexadecimal
33
Technique Divide the binary bits in group of 4’s, starting from the RIGHT Add 0’s to the last group to make it 4 bits Convert each grouped binary to their hexadecimal digits Binary to Hexadecimal E.g.: 1010111011 2 0010 1011 1011 2 11 (B) 11 (B) Start from the right ‘0’ bit 8 4 2 1 Ans: 2BB 16 8 4 2 1 0010 1011 1011 Divide the binary numbers into groups of 4’s. Add ‘0’ to the last group to make it 4 bits
34
Decimal to Octal DecimalOctal Binary Hexadecimal
35
Technique Divide by the base 8, keep track of the remainder Keep dividing until the quotient is 0. Take the remainder from the bottom and move upwards as the answer Decimal to Octal E.g.: Convert 1234 10 to octal Ans: 2322 8 Take the remainder from bottom upwards as answer
36
Decimal to Hexadecimal DecimalOctal Binary Hexadecimal
37
Technique Divide by the base 16, keep track of the remainder Keep dividing until the quotient is 0. Take the remainder from the bottom and move upwards as the answer Decimal to Hexadecimal E.g.: Convert 2079 10 to binary Ans: 81F 16 Take the remainder from bottom upwards as answer
38
Octal to Hexadecimal DecimalOctal Binary Hexadecimal
39
Technique First step: Convert the octal digits to their 3-bits binary Second step: Combined the binary obtained Third step: Divide the binary into groups of 4 (hexadecimal) starting from the RIGHT Fourth step: Find the hexadecimal digit from the grouped binary Octal to Hexadecimal E.g.: 1076 8 1 0 7 6 Start from the right ‘0’ bit 8 4 2 1 Ans: 23E 16 Divide the binary numbers into groups of 4’s. Add ‘0’ to the last group to make it 4 bits 001000111110 0010 / 0011 / 1110 8 4 2 1 14 (E)32
40
Hexadecimal to Octal DecimalOctal Binary Hexadecimal
41
Technique First step: Convert the hexadecimal digits to their 4-bits binary Second step: Combined the binary obtained Third step: Divide the binary into groups of 3 (octal ) starting from the RIGHT Fourth step: Find the octal digit from the grouped binary Hexadecimal to Octal E.g.: C45 16 C (12) 4 5 Start from the right ‘0’ bit 4 2 1 Ans: 6105 8 Divide the binary numbers into groups of 4’s. Add ‘0’ to the last group to make it 4 bits 110001000101 110 / 0 01 / 00 0 / 101 4 2 1 016 5
42
Binary Addition Binary addition between 2 1-bit values: ABA + B Z= A+B 000+00 010+11 101+01 111+110 “TWO”
43
10101 + 11001 101110 1 1 21 + 25 46 Two n-bit values Add individual bits Propagate carries E.g.: Binary Addition
44
ABA - BZ = A-B 000-00 010-11, borrow 1 101-01 111-10 Binary Subtraction Binary subtraction between 2 1-bit values:
45
1011 - 101 110 1 Binary Subtraction 10111 - 1001 - 1110 E.g.: 1001 – 10111 = ? 10111 is larger than 1001. So swap so that the larger number is in front and the smaller number is after. Subtract the numbers and negate the answer by putting the ‘-’ sign in front. Borrow ‘1’ from the next binary digit. Hence the number will become 10 which is equals to ‘2’. In situations like A – B, whereby the binary number ‘B’ is larger than A, swap the number so that B is in front: B – A. Then negate the answer: B – A = -Y
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.