13-08-2012, 11:22 AM
Number Systems, Base Conversions, and Computer Data Representation
1Number Systems.pdf (Size: 31.52 KB / Downloads: 180)
Decimal and Binary Numbers
For whole numbers, the rightmost digit position is the one’s position (100 = 1). The numeral in that
position indicates how many ones are present in the number. The next position to the left is ten’s,
then hundred’s, thousand’s, and so on. Each digit position has a weight that is ten times the
weight of the position to its right.
In the decimal number system, there are ten possible values that can appear in each digit
position, and so there are ten numerals required to represent the quantity in each digit position.
The decimal numerals are the familiar zero through nine (0, 1, 2, 3, 4, 5, 6, 7, 8, 9).
In a positional notation system, the number base is called the radix. Thus, the base ten system
that we normally use has a radix of 10. The term radix and base can be used interchangeably.
When writing numbers in a radix other than ten, or where the radix isn’t clear from the context, it
is customary to specify the radix using a subscript. Thus, in a case where the radix isn’t
understood.
In the binary number system, there are only two possible values that can appear in each digit
position rather than the ten that can appear in a decimal number. Only the numerals 0 and 1 are
used in binary numbers. The term ‘bit’ is a contraction of the words ‘binary’ and ‘digit’, and when
talking about binary numbers the terms bit and digit can be used interchangeably. When talking
about binary numbers, it is often necessary to talk of the number of bits used to store or represent
the number. This merely describes the number of binary digits that would be required to write the
number. The number in the above example is a 6 bit number.
Hexadecimal Numbers
In addition to binary, another number base that is commonly used in digital systems is base 16.
This number system is called hexadecimal, and each digit position represents a power of 16. For
any number base greater than ten, a problem occurs because there are more than ten symbols
needed to represent the numerals for that number base.
The reason for the common use of hexadecimal numbers is the relationship between the
numbers 2 and 16. Sixteen is a power of 2 (16 = 24). Because of this relationship, four digits in a
binary number can be represented with a single hexadecimal digit. This makes conversion
between binary and hexadecimal numbers very easy, and hexadecimal can be used to write large
binary numbers with much fewer digits. When working with large digital systems, such as
computers, it is common to find binary numbers with 8, 16 and even 32 digits. Writing a 16 or 32
bit binary number would be quite tedious and error prone. By using hexadecimal, the numbers
can be written with fewer digits and much less likelihood of error.
To convert a binary number to hexadecimal, divide it into groups of four digits starting with the
rightmost digit. If the number of digits isn’t a multiple of 4, prefix the number with 0’s so that each
group contains 4 digits. For each four digit group, convert the 4 bit binary number into an
equivalent hexadecimal digit. (See the Binary, BCD, and Hexadecimal Number Tables at the end
of this document for the correspondence between 4 bit binary patterns and hexadecimal digits)
Fixed Precision and Overflow.
So far, in talking about binary numbers, we haven’t considered the maximum size of the number.
We have assumed that as many bits are available as needed to represent the number. In most
computer systems, this isn’t the case. Numbers in computers are typically represented using a
fixed number of bits. These sizes are typically 8 bits, 16 bits, 32 bits, 64 bits and 80 bits. These
sizes are generally a multiple of 8, as most computer memories are organized on an 8 bit byte
basis. Numbers in which a specific number of bits are used to represent the value are called fixed
precision numbers. When a specific number of bits are used to represent a number, that
determines the range of possible values that can be represented.
Signed and Unsigned Numbers.
So far, we have only considered positive values for binary numbers. When a fixed precision
binary number is used to hold only positive values, it is said to be unsigned. In this case, the
range of positive values that can be represented is 0 -- 2n-1, where n is the number of bits used. It
is also possible to represent signed (negative as well as positive) numbers in binary. In this case,
part of the total range of values is used to represent positive values, and the rest of the range is
used to represent negative values.
There are several ways that signed numbers can be represented in binary, but the most common
representation used today is called two’s complement. The term two’s complement is somewhat
ambiguous, in that it is used in two different ways. First, as a representation, two’s complement is
a way of interpreting and assigning meaning to a bit pattern contained in a fixed precision binary
quantity. Second, the term two’s complement is also used to refer to an operation that can be
performed on the bits of a binary quantity. As an operation, the two’s complement of a number is
formed by inverting all of the bits and adding 1. In a binary number being interpreted using the
two’s complement representation, the high order bit of the number indicates the sign. If the sign
bit is 0, the number is positive, and if the sign bit is 1, the number is negative. For positive
numbers, the rest of the bits hold the true magnitude of the number. For negative numbers, the
lower order bits hold the complement (or bitwise inverse) of the magnitude of the number. It is
important to note that two’s complement representation can only be applied to fixed precision
quantities, that is, quantities where there are a set number of bits.