Lecture 03 PDF
Lecture 03 PDF
Number Systems
Range of Numbers and Overflow
When arithmetic operation such as Addition, Subtraction, Multiplication and
Division are performed on numbers the results generated may exceed the range of values
specified by the Binary representations. The values that exceed the specified range can
not be correctly represented and are considered as Overflow values.
The result indicates a negative number as the most significant bit is a 1. The answer is
incorrect as the result should be positive. The result indicates -7. The correct answer
+9 can not be represented using 4-bit 2’s complemented form, thus an Overflow has
occurred.
The carry generated is discarded. The result indicates a positive number as the most
significant bit is a 0. The answer is incorrect as the result should be negative. The
result indicates +7. The correct answer -9 can not be represented using 4-bit 2’s
complement form, thus an Overflow has occurred.
• One number is positive and its magnitude is larger than the negative number
0101 +5
1100 -4
10001 +1
• One number is positive and its magnitude is smaller than the negative number
1011 -5
0100 +4
1111 -1
Analysis of the four addition operation indicates that Overflow conditions can be
determined by looking at the most significant sign bits of the two numbers to be added
together and the most significant sign bits of the sum result. In the first two examples
where an Overflow has occurred the sign bits of both the numbers are the same indicating
both numbers to be positive or negative respectively. The sign bit of the sum term in both
cases is opposite to the signs of the two numbers being added together which can never
be. Thus the erroneous sign bits indicate the Overflow conditions.
Floating-Point Numbers
Modern computers can handle large binary numbers such as 64-bit unsigned
number, the maximum decimal number that can be represented using the 64-bit unsigned
representation is 264-1 which is nearly equal to1.84 x 1019.
How does a computer handle numbers larger than 264-1 or 1.84 x 1019 decimal?
Secondly, numbers used routinely are not only integer numbers but numbers such as 3.14
which have an integer part and a fraction part. Thirdly, how can very small numbers such
as 1.84 x 10-19 can be represented in Digital Systems?
Floating point numbers are defined using certain standards. The ANSI/IEEE
Standard 754 defines a 32-bit Single-Precision Floating Point format for binary numbers.
The 32-bit Single-Precision F.P. format is shown in Figure 3.1.
S Exponent Mantissa
• The single Sign (S) bit represents the sign of the number (0=positive 1=negative)
• The Exponent (E) 8 bits represent the exponent
• The Mantissa 23 bits represent the magnitude of the number
S E E M M M M M M M M M M M M
• The Sign (S) 1 digit represents the sign of the number (+/–)
• The Exponent (E) 2 digits represent the exponent
• The Mantissa 12 digits represent the magnitude of the number
+ 0 4 6 9 1 8 3 1 2 5 0 0 0 0
• Using this 15 digit (including the sign digit) notation the largest number that can be
represented is 0.999,999,999,999 x 1099
• Increase the Exponent field by one digit to allow for the sign to represent positive and
negative exponents. The total number of digits increases to 16.
• Used a Biased Exponent scheme. Instead of writing the exponent value directly add
the value 50 to the exponent and write the result in the exponent field. Using this
biased scheme the maximum positive exponent value that can be represented is 49
(49 + 50 = 99). The smallest exponent that can be represented is -50 (-50 + 50 = 0).
After allowing positive and negative exponent values to be represented, the range
of positive and negative decimal numbers that can be represented using the decimal f.p.
notation is 0.999,999,999,999 x 1049 to 0.999,999,999,999 x 10-50
• The number zero can be represented by setting al the Mantissa digits to 0. The Biased
exponent field can be set to any number and the sign field can be set to + or –
• The number infinity can not be represented.
• Allow numbers having the maximum and minimum exponent values to be 48 and -49
instead of 49 and -50. Thus the Biased exponent values would range between 98 (50
+ 48 = 98) and 01 (-49 + 50 = 1). The biased exponent value 00 can be used to
represent the number zero whatever the value of the mantissa. The biased exponent
value 99 can be used to represent the number infinity what ever the value of mantissa.
• Allow numbers having the maximum and minimum exponent values to be 49 and -48
instead of 49 and -50 and selecting 49 as the biased number. Thus the Biased
exponent values would range between 98 (49 + 49 = 98) and 01 (-48 + 49 = 1). The
biased exponent value 00 can be used to represent the number zero whatever the
value of the mantissa. The biased exponent value 99 can be used to represent the
number infinity what ever the value of mantissa. This approach is perhaps better as
the range of maximum positive exponent remains 49 and the range of values having a
negative exponent have been reduced to -48.
0 10001011 10110000011001010000000
Two floating point numbers can be added by adding together their mantissas
ensuring that the exponent parts of both the numbers are the same. If the exponents of the
two floating point numbers that are to be added together are not the same than decimal
point has to be adjusted for one of the floating point number to make both the exponents
equal. Similarly, two floating point numbers having the same exponents can be subtracted
by subtracting their corresponding mantissas. If the exponents of the two numbers to be
subtracted are not equal, then decimal point is adjusted to make the two exponents equal.
The 64-bit Double-Precision format sets aside 11 bits to represent the exponent as
Biased-1023 and a mantissa of 52 bits. A single bit, the most significant bit, is set aside
for the sign.
Hexadecimal Numbers
Representing even small number such as 6918 requires a long binary string
(1101100000110) of 0s and 1s. Larger decimal numbers would require lengthier binary
strings. Writing such long string is tedious and prone to errors.
The Hexadecimal number system is a base 16 number system and therefore has
16 digits and is used primarily to represent binary strings in a compact manner.
Hexadecimal number system is not used by a Digital System. The Hexadecimal number
system is for our convenience to long binary strings in a short and concise form. Each
Hexadecimal Number digit can represent a 4-bit Binary Number. The Binary Numbers
and the Hexadecimal equivalents are listed in Table 3.1
Counting in Hexadecimal
Counting in Hexadecimal is similar to the other number systems already
discussed. The maximum value represented by a single Hexadecimal digit is F which is
equivalent to decimal 15. The next higher value decimal 16 is represented by a
combination of two Hexadecimal digits 1016 or 10 H. The subscript 16 indicates that the
number is Hexadecimal 10 and not decimal 10. Hexadecimal Numbers are also identified
by appending the character H after the number. The Hexadecimal Numbers for Decimal
numbers 16 to 39 are listed in Table 3.2.
Binary strings which can not be exactly divided into a whole number of 4-bit groups are
assumed to have 0’s appended in the most significant bits to complete a group.
1. Indirect Method
A decimal number can be converted into its Hexadecimal equivalent indirectly by
first converting the decimal number into its binary equivalent and then converting the
binary to Hexadecimal.
1. Indirect Method
The indirect method of converting Hexadecimal number to decimal number is to
first convert Hexadecimal number to Binary and then Binary to Decimal.
2. Sum-of-Weights Method
A Hexadecimal number can be directly converted into Decimal by using the sum
of weights method. The conversion steps using the Sum-of-Weights method are shown.
1. Hexadecimal Addition
Carry 1
Number 1 2 A C 6
Number 2 9 2 B 5
Sum B D 7 B
2. Hexadecimal Subtraction
Borrow 1 1 1
Number 1 9 2 B 5
Number 2 2 A C 6
Difference 6 7 E F