Download presentation
Presentation is loading. Please wait.
Published byAudra Parsons Modified over 9 years ago
1
Lecture 2 Binary Values and Number Systems
2
The number 943 is an example of a number written in positional notation. The relative positions of the digits determine the values they represent. In base-10 each successive digit (reading from right to left) is worth ten times the previous position. In modern computers numbers are represented in base-2. This means that 0 and 1 are the only digits permitted and each position in a multi-digit number is worth two time the previous position. Positional Notation 943 10 = 9(100) + 4(10) + 3 110101 2 = 1(32) + 1(16) + 0(8) + 1(4) + 0(2) + 1 = 53 10
3
Binary, Octal, and Hexadecimal Numbers Base 2 (binary), base 8 (octal), and base 16 (hexadecimal) are all powers of 2 bases so it is easy to convert between them. Base 2 – digits 0,1 Base 8 – digits 0,1,2,3,4,5,6,7 Base 16 – digits 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17 0123456789ABCDEF0123456789ABCDEF binary octal hexadecimal 10111010001010101111000010101011 2 7 2 1 2 5 7 0 2 5 3 1011 1010 0010 1010 1111 0000 1010 1011 B A 2 A F 0 A B 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 decimal we can convert from base 2 to base 8 by evaluating groups of 3 bits at a time we an convert from base 2 to base 16 by evaluating groups of 4 bits at a time base 2 base 8 base 16 A single binary digit is called a bit. Eight bits is called a byte, four bits is called a nibble.
4
Converting Between Base 10 and Base 2 Let’s convert 142 to base 2 142/2 = 71 remainder 0 71/2 = 35 remainder 1 35/2 = 17 remainder 1 17/2 = 8 remainder 1 8/2 = 4 remainder 0 4/2 = 2 remainder 0 2/2 = 1 remainder 0 1/2 = 0 remainder 1 10001110 Let’s convert 101100101 to base 10 1 = 1 10 = 2x1 = 2 101 = 2x2 + 1 = 5 1011 = 2x5 + 1 = 11 10110 = 2x11 = 22 101100 = 2x22 = 44 1011001 = 2x44 + 1 = 89 10110010 = 2x89 = 178 101100101 = 2x178 + 1 = 357 1 4 32 64 256 357 + Left to Right Evaluation
5
10001010 + 10111000 00101110 Base 2 Arithmetic optional Addition Converting a Number to Two’s Complement* *Two’s complement is a special way to represent negative values for base-2 integers. 00011101 11100010 + 1 11100011 this is the base 2 representation for 29 flip all the bits add 1 this is the two’s complement representation for -29 01111011 11100011 Subtraction + 101011110 ignore overflow this is 123 this is -29 this is 94 When the binary value has a leading 1, the number is negative...to find the magnitude of this value we need to take the two’s complement again. Lets add -29 to 12... 00001100 + 11100011 11101111 most significant digit a 1 means values is negative 11101111 00010000 + 1 00010001 magnitude is 17 so 11100011 = -17
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.