Data Representation and Number system
Numeric systems
The numeric system we use daily is the decimal system, but this system i s not convenient f or
machines since the information is handled codified in the shape of on or off bits; this way of
codifying takes us to the necessity of knowing the positional calculation which will allow us to
express a number in any base where we need it.
Radix number systems
A base of a number system or radix defines the range of values that a digit may have. In the
binary system or base 2, there can be only two values for each digit of a number, either a "0" or a
"1".
In the octal system or base 8, there can be eight choices for each digit of a number:
"0", "1", "2", "3", "4", "5", "6", "7".
In the decimal system or base 10, there are ten different values for each digit of a number:
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9".
In the hexadecimal system, we allow 16 values for each digit of a number:
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", and "F".
Where “A” stands for 10, “B” for 11 and so on.
Conversion among radices –
Convert from Decimal to Any Base
Let’s think about what you do to obtain each digit. As an example, let's start with a decimal
number 1234 and convert it to decimal notation. To extract the last digit, you move the decimal
point left by one digit, which means that you divide the given number by its base 10.
1234/10 = 123 + 4/10
The remainder of 4 is the last digit. To extract the next last digit, you again move the decimal
point left by one digit and see what drops out.
123/10 = 12 + 3/10
The remainder of 3 is the next last digit. You repeat this process until there is nothing left. Then
you stop. In summary, you do the following:
Now, let's try a nontrivial example. Let's express a decimal number 1341 in binary notation. Note
that the desired base is 2, so we repeatedly divide the given decimal number by 2.
Let's express the same decimal number 1341 in octal notation.
Let's express the same decimal number 1341 in hexadecimal notation.
In conclusion, the easiest way to convert fixed point numbers to any base is to convert each part
separately. We begin by separating the number into its integer and fractional part. The integer
part is converted using the remainder method, by using a successive division of the number by
the base until a zero is obtained. At each division, the reminder is kept and then the new number
in the base r is obtained by reading the remainder from the remainder upwards.
The conversion of the fractional part can be obtained by successively multiplying the fraction
with the base. If we iterate this process on the remaining fraction, then we will obtain successive
significant digit. This methods form the basis of the multiplication methods of converting
fractions between bases
Example.
Convert the decimal number 3315 to hexadecimal notation. What about the hexadecimal
equivalent of the decimal number 3315.3?
Convert From Any Base to Decimal
Let's think more carefully what a decimal number means. For example, 1234 means that there are four
boxes (digits); and there are 4 one's in the right-most box (least significant digit), 3 ten's in the next box, 2
hundred's in the next box, and finally 1 thousand's in the left-most box (most significant digit). The total
is 1234:
Thus, each digit has a value: 10^0=1 for the least significant digit, increasing to 10^1=10,
10^2=100, 10^3=1000, and so forth.
Likewise, the least significant digit in a hexadecimal number has a value of 16^0=1 for the least
significant digit, increasing to 16^1=16 for the next digit, 16^2=256 for the next, 16^3=4096 for
the next, and so forth. Thus, 1234 means that there are four boxes (digits); and there are 4 one's
in the right-most box (least significant digit), 3 sixteen's in the next box, 2 256's in the next, and
1 4096's in the left-most box (most significant digit). The total is:
1*4096 + 2*256 + 3*16 + 4*1 = 4660
In summary, the conversion from any base to base 10 can be obtained from the formulae
Where b is the base, di the digit at position i, m the number of digit after the
decimal point, n the number of digits of the integer part and X10 is the obtained number in
decimal. This form the basis of the polynomial method of converting numbers from any base to
decimal
Example
Convert 234.14 expressed in an octal notation to decimal.
2*82 + 3*81 + 4*80+1*8-1 + 4*8-2 = 2*64 +3*8 +4*1 +1/8 +4/64 =156.1875
Signed fixed point numbers (Start the Data Representation)
Binary Logic
Introduction
Binary logic deals with variables that assume discrete values and with operators that assume
logical meaning. While each logical element or condition must always have a logic value of
either "0" or "1", we also need to have ways to combine different logical signals or conditions to
provide a logical result.
For example, consider the logical statement: "If I move the switch on the wall up, the light will
turn on." At first glance, this seems to be a correct statement. However, if we look at a few other
factors, we realize that there's more to it than this. In this example, a more complete statement
would be: "If I move the switch on the wall up and the light bulb is good and the power is on, the
light will turn on."
If we look at these two statements as logical expressions and use logical terminology, we can
reduce the first statement to:
Light = Switch
This means nothing more t han that the light will follow the action o f the switch, s o that when
the switch is up/on/true/1 the light will also be on/true/1. Conversely, if the switch is
down/off/false/0 the light will also be off/false/0.
Looking at the second version of the statement, we have a slightly more complex expression:
Light = Switch and Bulb and Power
When we deal with logical circuits (as in computers), we not only need to deal with logical
functions; we also need some special symbols to denote these functions in a logical diagram.
There are three fundamental logical operations, from which all other functions, no matter how
complex, can be derived. These functions are named and, or, and not. Each of these has a
specific symbol and a clearly-defined behavior.
AND. The AND operation is represented by a dot(.) or by the absence of an operator. E.g. x.y=z
xy=z are all read as x
AND y=z. the logical operation AND is interpreted to mean that z=1 if and only if x=1 and y=1
otherwise z=0
OR. The operation is represented by a + sign for example, x+y=z is interpreted as x OR y=z
meaning that z=1 if x=1 or y=1 or if both x=1 and y=1. If both x and y are 0, then z=0
NOT. This operation is represented by a bar or a prime. For example x′= what x is not
x =z is interpreted as NOT x =z meaning that z should be noted that although the A ND and the
OR operation have some similarity with the multiplication and addition respectively in binary
arithmetic, however one should note that an arithmetic variable may consist of many digits. A
binary logic variable is always 0 or 1.
e.g. in binary arithmetic, 1+1=10 while in binary logic 1+1=1
Basic Gate
The basic building blocks of a computer are called logical gates or just gates. Gates are basic
circuits that have at least one (and usually more) input and exactly one output. Input and output
values are the logical values true and false. In computer architecture it is common to use 0 for
false and 1 for true. Gates have no memory. The value of the output depends only on the current
value of the inputs. A useful way of describing the relationship between the inputs of gates and
their output is the truth table. In a truth table, the value of each output is tabulated for every
possible combination of the input values.
Typically, not all gate types are used in implementation. Design and fabrication are simpler if
only one or two types of gates are used. Thus, it is important to identify functionally complete
sets of gates. This means that any Boolean function can be implemented using only the gates in
the set.
The following are functionally complete sets:
• AND, OR, NOT
• AND, NOT
• OR, NOT
• NAND
• NOR
The Use of NAND Gates
It should be clear that AND, OR, and NOT gates constitute a functionally complete set, because
they represent the three operations of Boolean algebra. For the AND and NOT gates to form a
functionally complete set, there must be a way to synthesize the OR operation from the AND and
NOT operations. This can be done by applying DeMorgan’s theorem:
A+B=A•B
A OR B = NOT ((NOT A) AND (NOT B))
Similarly, the OR and NOT operations are functionally complete because they can be used to
synthesize the AND operation. Figure below shows how the AND, OR, and NOT functions can
be implemented solely with NAND gates, and Figure below shows the same thing for NOR
gates.
The use of NOR Gates
For this reason, digital circuits can be, and frequently are, implemented solely with NAND gates
or solely with NOR [Link] gates, we have reached the most primitive circuit level of
computer hardware. An examination of the transistor combinations used to construct gates
departs from that realm and enters the realm of electrical engineering. For our purposes,
however, we are content to describe how gates can be used as building blocks to implement the
essential logical circuits of a digital computer.
BOOLEAN ALGEBRA
The digital circuitry in digital computers and other digital systems is designed, and its behavior is
analyzed, with the use of a mathematical discipline known as Boolean algebra. The name is in
honor of an English mathematician George Boole, who proposed the basic principles of this
algebra in 1854 in his treatise, An Investigation of the Laws of Thought on Which to Found the
Mathematical Theories of Logic and Probabilities.
(a) Boolean Operators of Two Input Variables
(b) Boolean Operators Extended to More than Two Inputs (A, B, . . .)
Several points concerning the notation are needed. In the absence of parentheses, the
AND operation takes precedence over the OR operation. Also, when no ambiguity will
occur, the AND operation is represented by simple concatenation instead of the dot
operator. Thus,
A + B · C = A + (B · C) = A + BC
all mean: Take the AND of B and C; then take the OR of the result and A. Table above
defines the basic logical operations in a form known as a truth table, which lists the value
of an operation for every possible combination of values of operands. The table also lists
three other useful operators: XOR, NAND, and [Link] exclusive-or (XOR) of two
logical operands is 1 if and only if exactly one of the operands has the value 1. The
NAND function is the complement (NOT) of the AND function, and the NOR is the
complement of OR:
A NAND B = NOT (A AND B) = AB
A NOR B = NOT (A OR B) = A + B
As we shall see, these three new operations can be useful in implementing certain digital
circuits. The logical operations, with the exception of NOT, can be generalized to more
than two variables, as shown in below. Table below summarizes key identities of
Boolean algebra. Equations have been arranged in two columns to show the
complementary, or dual, nature of the AND and OR operations. There are two classes of
identities: basic rules (or postulates), which
Basic Identities of Boolean Algebra
are stated without proof, and other identities that can be derived from the basic postulates.
The postulates define the way in which Boolean expressions are interpreted. One of the
two distributive laws is worth noting because it differs from what we would find in
ordinary algebra:
A + (B · C) = (A + B) · (A + C)
The two bottommost expressions are referred to as DeMorgan’s theorem. We can restate
them as follows:
A NOR B = A AND B
A NAND B = A OR B