Lecture 5 . Topics. Sec 1.4 Representing Information as Bit Patterns Representing Text Representing Numeric Values Representing Images Sec 1.6 Storing Integers Two’s Complement Notation Excess Notation. Representing Text.
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
Sec 1.4 Representing Information as Bit Patterns
Representing Numeric Values
Sec 1.6 Storing Integers
Two’s Complement Notation
Resolutionrefers to the sharpness or clarity of an image
There are two ways to represent Signed Integers:
Two’s complement notation: The most popular means of representing integer values
Excess notation: Another means of representing integer values
Both can suffer from overflow errors.
Can use “+” and “-”, as usual.
But requires extra symbols. How can we use bits instead?
Invert all bits, then add 1.
+ 0010(2 decimal)
= (5 decimal ?)
+ 1110(-2 decimal)
= (-5 decimal ?)
+ 1110(-2 decimal)
= (1 decimal ?)
0011 (3 decimal)
+ 0111(7 decimal)
= 1010 (-6 decimal???)
Excess 8 notation indicates that the value for zero is the bit pattern for 8, that is 1000
The bit patterns are 4 bits long
Positive numbers are above it in order and negative numbers are below it in order.
That is the zero point for Excess 128 notation is 128; the zero point for excess 64 notation is 64; and so forth.
For example, let's say we want to determine the pattern for 15 in Excess 128 notation.
The decimal number would be 128 + 15, or 143. Therefore, the bit pattern would be 10001111.
In contrast to storage of Integers the storage of fractions requires not only the representation of the magnitude by the radix point as well
A popular way of doing this is based on scientific notation called Floating-Point Notation
2-1 = 1/22-2 = 1/42-3 = 1/8
We use a radix point in the same role as the decimal point in decimal notation. That is, the digits to the left of the radix point represent the integer part of the value. The digits to the right represent the fractional part of the value.
_ _ _ . _ _ _
22 21 20 2-1 2-2 2-3
101.101 is 5 5/8 and 101.01011 is 5 11/32
Let's look at some decimal numbers first, to get a feel for what needs to be done. First we need to know how many digits in the mantissa. Let's choose 5.
The last example shows us one of the problems with floating-point notation – truncation error. Part of the value being stored is lost because the mantissa field is not large enough.
Now let's switch to binary. Although a common standard uses 64 bits for a floating-point number: 1 bit for the sign, 11 bits for the exponent, and 52 bits for the mantissa, we will use an abbreviated version. Let's use one byte: 1 bit for the sign, 3 bits for the exponent, and 4 bits for the mantissa.
The sign is easy enough 0 or 1.
The exponent has 3 bits and must be either + or -. We could use 2's complement, but excess notation is used instead! 3 bits means excess 4 notation. That leaves 4 bits for the mantissa. Why excess notation? It gives the best range of exponents and ease of wiring the circuitry.
000 0 – 4 = -4001 1 – 4 = -3010 2 – 4 = -2011 3 – 4 = -1100 4 – 4 = 0101 5 – 4 = 1110 6 – 4 = 2111 7 – 4 = 3
Determine the sign bit
Convert the whole number to binary
Convert the fraction to binary
Move the radix to the left of the most significant digit (left-most non-zero digit)
Determine the exponent in excess 4 notation
To store 1 1/8 we express it in binary notation and obtain 1.001
Copy the bit patterns into the mantissa field from left to right.