Download Binary Representation of Large Values and Negative Numbers and more Slides Aeronautical Engineering in PDF only on Docsity! Finding Binary Representation of Large Values 1. Divide the value by 2 and record the remainder 2. As long as the quotient obtained is not 0, continue to divide the newest quotient by 2 and record the remainder 3. Now that a quotient of 0 has been obtained, the binary representation of the original value consists of the remainders listed from right to left in the order they were recorded The Binary System 10 = 5x103 + 3x102 +8x101 +2x100 – 10112 = 1x23 + 0x22 + 1x21 + 1x20 = 8 + 0 + 2 + 1 = 1110 • Binary addition • A byte 0 1 0 1 0 0 1 1 7 6 5 4 3 2 1 0 1248163264128 bit number bit value – 5382 2 1 0 R1 2 3 1 R1 2 6 0 R0 2 13 6 R1 1 1 0 1 • Decimal: Position represents a power of 10 • Binary: Position represents a power of 2 docsity.com Representing Negative Numbers 2 = 1910. How to represent - 1910 in binary? number (sign magnitude) – 000000012 = 110 100000012 = -110 – 000100112 = 1910 100100112 = -1910 Representing Negative Numbers – 000100112 = 1910 111011002 = -1910 – 010: 000000002 and 111111112 add 1 – 000100112 = 1910 111011012 = -1910 – Try to negate 0: • 010 = 000000002 • invert: 000000002 Æ 111111112 • 2 + 000000012 = 000000002 representing negative numbers? add 1: 11111111 • Using one byte, any suggestions for – E.g., 00010011 • Reserve 1 bit (#7) for sign, 7 bits for • One’s complement – invert each bit • Two’s complement – invert each bit and docsity.com The Problem of Overflow represented falls outside the range of values that can be represented. of two positive values results in the pattern for a negative value or vice versa. accumulate to produce large numbers. Fractions in Binary twice the size of the one to its right. 10.001 + 100.000 111.001 22 21 20 2-1 2-2 2-3 4 2 1 1/2 1/4 1/8 1 0 1 . 1 0 1 4 + 0 + 1 + 1/2+ 0 +1/8 = 5 5/8 • Overflow: when a value to be • An overflow is indicated if the addition • Remember: small values can • Each position is assigned a quantity of • 101.101 = ? 1. Binary place 2. Position's quantity 3. Example binary pattern 4. Total (2 x 3) docsity.com Floating Point representation the number is divided into two parts: the integer and the fraction numbers Floating Point representation part and 4 bits to represent the fraction: 71.3425 = +1000111.0101 • To represent a floating point number – 3.1415 has integer 3 and fraction 0.1415 • Converting FP to binary: – Convert integer part to binary – Convert fraction part to binary – Put a decimal point between the two • Assume 12 bits to represent the integer docsity.com Normalization point •Instead we use Normalization Move the decimal point so that there is only one 1 to the left of the decimal point. e where e is the number of bits that the decimal point moved, positive for left movement, negative for right movement Store: The sign The exponent The mantissa Excess (or bias) Notation • the exponent for floating point numbers. With 3 bits we have excess 4 (=23-1) Alternative to two’s complement used to store Bit positions ExponentSign bit 3 2 1 0 • To represent +1000111.0101 – Store sign, all bits, and the position of decimal To indicate the original value of the number, multiply by 2 Mantissa 111 Bit Pattern Value Represented 110 101 100 011 010 001 000 -1 -2 -3 -4 docsity.com