250 likes | 657 Views
Excess Notation: One format that can be used to represent signed integers. Excess notation always uses a fixed number of bits with the leftmost bit representing the sign. The value zero is represented by a bit string with a one in the leftmost digit and zeros in all of the other digits.
E N D
Excess Notation: • One format that can be used to represent signed integers. • Excess notation always uses a fixed number of bits with the leftmost bit representing the sign. • The value zero is represented by a bit string with a one in the leftmost digit and zeros in all of the other digits.
To represent a specific integer value in excess notation you must know how many storage bits are to be used, whether the value fits within the numeric range of excess notation for that number of bits, and whether the value to be stored is positive or negative. • For any number of bits, the largest and smallest values in excess notation will be 2(n-1)-1 and -2n-1, where n is the number of available storage bits.
For example, consider storing a signed integer in 8 bits using excess notation. • Because the leftmost bit is a sign bit, the largest positive value that can be stored is 27-1, or 12710, and the smallest negative value that can be stored is -27, or -12810. • The range of positive values appears to be smaller than the range of negative values because zero is considered a positive (nonnegative) number in excess notation.
Now consider how +9 and -9 are represented in 8-bit excess notation. • The ordinary binary representation of +910 in 8 bits is 00001001. • zero is always a leading one-bit followed by all zero-bits—10000000 for 8-bit excess notation. • Since +9 is nine integer values greater than zero, we can calculate the representation of +9 by adding its ordinary binary representation to the excess notation representation of zero as follows: 10000000 + 00001001 = 10001001
To represent negative values, we use a similar method based on subtraction. • Since -9 is nine integer values less than zero, we can calculate the representation of -9 by subtracting its ordinary binary representation from the excess notation representation of zero as follows: 10000000 – 10001001 = 01110111
Two’s Complement: • the complement of 0 is 1 and the complement of 1 is 0. • The complement of a bit string is formed by substituting 0 for all values of 1 and 1 for all values of 0 (the complement of 1010 is 0101). • In this notation, nonnegative integer values are represented as ordinary binary values. For example, a two's complement representation of 710 using four bits is: 0111.
Bit strings for negative integer values are determined by the following transformation: Complement of positive value + 1 = negative representation
Examples: • Two’s Complement Addition: • 5 + (-3) = 2 0000 0101 = +5 + 1111 1101 = -3 0000 0010 = +2 • Two’s Complement Subtraction: • 7 - 12 = (-5) 0000 0111 = +7 + 1111 0100 = -12 1111 1011 = -5 • Two’s Complement Multiplication: • (-4) × 4 = (-16) 1111 1100 = -4 × 0000 0100 = +4 1111 0000 = -16
Two’s Complement Division: • 7 ÷ 3 = 2 remainder 1 0000 0111 = +7 0000 0100 = +4+ 1111 1101 = -3 + 1111 1101 = -3 0000 0100 = +4 0000 0001 = +1 (remainder) • Exponential: • 3 exp 3 = 3 * 3 * 3 = (3 *3) * 3 = (3+3+3) * 3 = 3 * 3 + 3 * 3 + 3 * 3 = (3+3+3) + (3+3+3) +(3+3+3) = 27.in binary: (11+11+11) + (11+11+11) + (11+11+11) = 11011.
Range and Overflow: • Most modern CPUs use either 32 or 64 bits to represent a two's complement value (we'll assume 32 bits for the remainder of this text unless otherwise specified). • Overflow is an error occurred in the CPU where more bits are generated in an arithmetic operation (too many bits that can’t be stored).
extra bits increase processor complexity and storage requirements, which, in turn, increase computer system cost. • To avoid overflow and to increase accuracy, some computers and programming languages define additional numeric data types called double precision data formats. • A double precision data format combines two adjacent fixed-length data items to hold a single value.
Double precision integers sometimes are called long integers.
Real Numbers: • A real number can contain both whole and fractional components. • The fractional portion is represented by digits to the right of the radix point. • For example : 18/4 = 4.5, the result is real number that is equivalent to the binary: 10010/100 = 100.1 • Representing a real number within computer circuitry requires some way to separate the whole and fractional components of the value 1- Radix Point. 2- Floating Point.
1- Radix Point Notation: A simple way to accomplish this is to define a storage format in which a fixed-length portion of the bit string holds the whole portion and the remainder of the bit string holds the fractional portion.
simple due to the fixed location of the radix point. • The advantage of this simplicity is simpler and faster CPU processing circuitry. • Unfortunately, that processing efficiency is gained by limiting numeric range.
2- Floating Point Notation: • One way of dealing with the tradeoff between range and precision is to abandon the concept of a fixed radix point. • To represent extremely small (precise) values, move the radix point far to the left. For example, the value: 0.0000000013526473 has only a single digit to the left of the radix point.
Similarly, very large values can be represented by moving the radix point far to the right, as in: 1352647300000000.0 • Note that both examples have the same number of digits. • The first example trades range of the whole portion for increased fractional precision, and the second example trades fractional precision for increased whole range by having the radix point float left or right.
people often write large numbers in a more compact format called scientific notation. • In scientific notation the previous two numbers are represented as 13,526,473 x 10-16 and 13,526,473 x 108
Floating point notation is similar to scientific notation except that 2 (rather than 10) is the base. • A numeric value is derived from a floating point bit string according to the following formula: value = mantissa x 2exponent • The mantissa holds the bits that are interpreted to derive the digits of the real number.