Download presentation
Presentation is loading. Please wait.
Published byClare Turner Modified over 6 years ago
1
Binary / Hex Binary and Hex The number systems of Computer Science
2
Main Memory Memory cells have two states:
On Off Work best with two-state number system --- Binary number system Investigate Decimal number system first
3
The Decimal Numbering System
The decimal number system is a positional number system: the same digit will have different values in different positions. Examples: 5 “five” = 5 * “fifty” = 5 * “five-hundred” = 5*100
4
The Decimal Numbering System
Combinations yield any integer. Example: X 100 X 101 6 X 102 5 X 103
5
What is the base ? The decimal numbering system is also known as base 10. The values of the positions are calculated by taking 10 to some power. The common number system is a decimal or base 10 system because we use 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
6
(Can you feel the tension building?)
What is the base ? The binary numbering system is called binary because it uses base 2. The values of the positions are calculated by taking 2 to some power. The Binary system uses just two digits: 0 and 1 A memory cell has just two states… (Can you feel the tension building?)
7
The Binary Numbering System
The Binary Numbering System is also a positional numbering system. Instead of ten digits, 0 - 9, the binary system uses only two digits, 0 and 1. Example of a binary number & the values of the positions. ( = 65)
8
Computing the Decimal Values of Binary Numbers
X 20 = 1 X 21 = 0 0 X 22 = 0 20 = = X 23 = 0 21 = = X 24 = 0 22 = = X 25 = 0 23 = X 26 =
9
Converting Decimal to Binary
First make a list of the values of 2 to the powers of 0 to 8, then use the subtraction method. 20 = 1, 21 = 2, 22 = 4, 23 = 8, 24 = 16, 25 = 32, 26 = 64, 27 = 128, 28 = 256 Example:
10
Counting in Binary Binary 1 10 11 100 101 110 111 Decimal equivalent 1
1 10 11 100 101 110 111 Decimal equivalent 1 2 3 4 5 7 8
11
Addition of Binary Numbers
Examples:
12
Addition of Large Binary Numbers
Example showing larger numbers:
13
Working with large numbers
Humans can’t work well with binary numbers. We will make errors. * Hexadecimal: Shorthand for binary
14
Hexadecimal Binary 0 1 0 1 0 0 0 0 1 0 0 1 0 1 1 1 Hex 5 0 9 7
Written:
15
The Amazing Secret of Hexadecimal Notation!
Binary Hex The amazing secret: 16 = 28
16
Hexadecimal Binary is base 2 two digits: 0, 1
Decimal is base 10 ten digits: 0, 1, 3, 4, 5, 6, 7, 8, 9. Hexadecimal (hex) is base 16. How many digits do we need to express numbers in hex? 16: A B C D E F
17
Counting in Hex Binary Hex Binary Hex 0 0 0 0 0 1 0 0 0 8
A B C D E F
18
Another Binary to Hex Conversion
Hex C F 7C3F16
19
Storing Negative Numbers in Binary
Since we need to store negative numbers as well as positive numbers in binary, special variations on binary are used. 2’s Complement notation is used for integers.
20
Building the 2’s Complement of a Binary Number
Start with a binary number x = Replace 1 by 0, replace each 0 by 1 x1 = (“one’s complement”) Add 1 to the least significant digit x2 = (“two’s complement”)
21
Why Two’s Complement? Adding the two’s complement of a number is like subtracting the number x+x2 = (1) where the leading 1 is in parentheses because it will be ignored. Replaces Subtraction by Addition
22
Review The decimal, binary, and hexadecimal number systems are positional systems The decimal number system has 10 digits, the binary system two, the hexadecimal system has 16 The binary system is good system to use for two state memory devices.
23
Review The hexadecimal system (“hex”) needs 16 digits, so it uses 0-9,A,B,C,D,E,F The hexadecimal system is a often a convenient shorthand for the binary system: 4-bits to one hex digit Negative numbers are stored using “two’s complement” which turns subtraction into addition.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.