0% found this document useful (0 votes)
2K views18 pages

STLD UNIT-I Notes

Uploaded by

injetisobharani
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views18 pages

STLD UNIT-I Notes

Uploaded by

injetisobharani
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

Philosophy of number systems:

 To convert a number from one system (decimal, binary, octal,


hexadecimal) to its equivalent in one of the other, we have different
types of number systems, namely

1. Decimal systems

2. Binary systems

3. Octal systems

4. Hexadecimal systems

1. Decimal Number System:

Decimal means base 10 (the prefix dec). In any number system, given
the base (often referred to as radix), the number of digits that can be used to
count is fixed. For example in the base 10 number system, the digits that
can be used to count are 0,1,2,3,4,5,6,7,8,9.

Generalizing that for any base b, the first b digits (starting with
0) represent the digits that are used to count. When a number ≥ b has to be
represented, the place values are used.

Example: Consider the number 1234.567. It is represented as

1*103+ 2*102 + 3*101 + 4*100+ 5*10-1+ 6*10-2+ 7*10-3

Where:

• 5 is in the tenth’s place


• 6 is in the hundredth’s place
• 7 is in the thousandth’s place

In the above equation, the representation includes digits both to the left
and to the right of the decimal point.

2. Binary Number System :

Binary means base 2 (the prefix bi). The 0, 1 used in the binary system
are called binary digits (bits).

The bit is the smallest piece of information that can be stored in a


computer. It can have one of two values 0 or 1. Think of a bit as a switch that
can be either on or off.

For example,

From the hardware perspective, ON and OFF can be represented as voltage


levels (typically 0V for logic 0 and +3.3 to +5V for logic 1). Since only two
values can be stored in a bit, we combine a series of bits to represent more
information.

Example: Consider the binary number 1101.101. It can be represented as:

1*23+ 1*22 + 0*21 + 1*20+ 1*2-1+ 0*2-2+ 1*2-3

The same notation is applicable to real numbers represented in binary


notation. The equivalent decimal number is

13 + 0.5 + 0 + 0.125 = 13.625


To represent larger numbers, we have to group series of bits. Two of these
groupings are of importance:

Nibble - A nibble is a group of four bits

Byte - A byte is a group of eight bits

3. Octal Number System:

Octal means base 8 (the prefix octal). 8 different possible digits are
0,1,2,3,4,5,6,7. Each position in decimal number is weighted by a factor of 8.

4. Hexa Decimal Number System:

Hexa Decimal means base 16 (the prefix Hex). Composed of 16


numerals or symbols 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F. Use 4 bits group

Decimal Binary Octal Hexa Decimal


0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
16 10000 20 10
17 10001 21 11
18 10010 22 12
19 10011 23 13

 Conversions between Number Systems:

• Decimal to binary
• Decimal to octal
• Decimal to hex
• Binary to decimal
• Binary to octal
• Binary to hex
• Octal to decimal
• Octal to binary
• Octal to hex
• Hex to decimal
• Hex to binary
• Hex to octal

Decimal to binary:
Repeatedly dividing the decimal number by 2and writing down the
reminder after each division until a quotation of 0 is obtained.
Decimal to octal:
Repeatedly dividing the decimal number by 8 and writing down the
reminder after each division until a quotation of 0 is obtained. The reminder
can be obtained by multiplying the decimal fraction by 8.

Example: 266/8 = 33.25


The remainder becomes; 0.25 x 8 = 2

Decimal to hex:
Repeatedly dividing the decimal number by 16 and writing down the
reminder after each division until a quotation of 0 is obtained. T he reminder
can be obtained by multiplying the decimal fraction by 16.

Example: 214/16 =13.375


The remainder becomes; 0.375 x 16 = 6

Binary to decimal:
Summing together the weights of the various positions in the binary
number.
Binary to octal:
The bits of binary number are grouped of three bits starting at the LSB.
Then each group is converted to its octal equivalent.

Binary to hex:
The binary number is grouped into groups of 4 bits and each group is
converted to its equivalent hex digit. Zeros are added, as needed, to
complete 4 bit group.

Octal to decimal:
Multiply each octal digit by its positional weight. Then sum all together.
Octal to binary:
Convert each octal digit to its 3 bit binary equivalent.

Hex to decimal:
Sum of weight.

Hex to binary:
Each hex digit is converted to its four-bit binary equivalent.
Complement representation of negative numbers:
 Negative Numbers:
Negative binary numbers are represented by the ‘-’ sign followed by
the magnitude of the number. The computer however does not have a
means of representing signs. The sign has to be captured in the bit pattern
itself.

 Signed Magnitude Representation:


The signed magnitude representation uses the most significant bit to
determine if the number is positive or negative. The advantage of this
notation is that by examining the msb alone, it is possible to determine if the
number is positive or negative. The disadvantage however is that one bit
pattern is wasted (there are two possible representations for zero) and
subtraction cannot be performed using addition alone.
Numbers using 4-bit signed magnitude representation
Note: +0 and –0 have different bit patterns.
Example: Consider the following operation 7 – 2. Substituting the bit
patterns from the table.

The bit pattern 0001 is 1 but the result should by 5 0101.

 One’s Complement:
The one’s complement notation represents a negative number by
inverting the bits in each place. Again the limitations of the sign magnitude
representation are not overcome (there are two bit patterns used to
represent 0 and the addition operation cannot be used to perform
subtraction). The one’s complement is important because it is very easy to
perform the inversion operation in hardware and it forms the basis of
computing the two’s complement.

Numbers using 1’s complement representation


Example: Consider the following operation 7 – 2. Substituting the bit
patterns from the table.

The bit pattern 0100 is 4 but the result should by 5 0101.

 Two’s Complement:
The two’s complement notation builds on the one’s complement
notation. The algorithm goes as follows:
• Compute the 1’s complement.
• Add 1 to the result to get the 2’s complement.
The two’s complement notation has the advantages that the sign of
the number can be computed by looking at the msb. The addition operation
can be used to perform subtraction. Also, there is only one bit-pattern to
represent ‘0’ so an extra number can be represented.

Numbers using 2’s complement representation


Example: Consider the following operation 7 – 2. Substituting the bit
patterns from the table.

The bit pattern 0101 is 5, which is the expected result.


The limitation with the 2’s complement notation is that the bit patterns
are not in order i.e. comparing the bit patterns alone does not provide any
information as to which number is larger.
Binary arithmetic:

 Binary Addition:
The rules for binary addition are the same as those for any positional
number system. One adds the digits column-wise from the right. If the sum
is greater than B–1 for base B, a carry into the next column is generated. In
the case of binary numbers, a sum greater than one generates a carry.
Here is the binary addition table:
The first three entries are self-explanatory. The third entry is
1+1=102, or one plus one is two; we have a sum of zero and a carry of one
into the two’s place. The fourth entry is 1+1+1=112, or three ones are
three. The sum is one and there is a carry into the two’s place.

The truth table for one-bit binary addition looks like this:

• Addition of Signed Numbers:


Binary addition of two’s complement signed numbers can be
performed using the same rules given above for unsigned addition. If there
is a carry out of the sign bit, it is

 Binary Subtraction:
Subtraction is also the same as in decimal, except, 0 -1 = 1 with a 1
borrowed: i.e. borrow 1 from the left and add 2 to the digit on the right, just
as you would add 10 if working in decimal.

 Binary Multiplication:
The rules are the same as in decimal.
Notice that no true multiplication is necessary in forming the partial
products. The fundamental operations required are shifting and addition.
This means we can multiply unsigned or positive integers using only shifters
and adders.

 Binary Division:
The rules are the same as in decimal.

Let us divide 0110101 (5310) by 0101 (510). Beginning at the left of


the dividend, we move to the right one digit at a time until we have identified
a portion of the dividend which is greater than or equal to the divisor. At this
point a one is placed in the quotient; all digits of the quotient to the left are
assumed to be zero. The divisor is copied below the partial dividend and
subtracted to produce a partial remainder as shown below.

Now digits from the dividend are “brought down” into the partial
remainder until the partial remainder is again greater than or equal to the
divisor. Zeroes are placed in the quotient until the partial remainder is
greater than or equal to the divisor, then a one is placed in the quotient, as
shown below.

The divisor is copied below the partial remainder and subtracted from
it to form a new partial remainder. The process is repeated until all bits of
the dividend have been used. The quotient is complete and the result of the
last subtraction is the remainder.

This completes the division. The quotient is 10102 (1010) and the
remainder is 112 (310 ), which is the expected result. This algorithm works
only for unsigned numbers, but it is possible to extend it to two’s
complement numbers.

Binary Codes:

Internally, digital computers operate on binary numbers. When


interfacing to humans, digital processors, e.g. pocket calculators,
communication is decimal-based. Input is done in decimal then converted to
binary for internal processing. For output, the result has to be converted
from its internal binary representation to a decimal form. To be handled by
digital processors, the decimal input (output) must be coded in binary in a
digit by digit manner.

One commonly used code is the Binary Coded Decimal (BCD) code
which corresponds to the first 10 binary representations of the decimal digits
0-9. The BCD code requires 4 bits to represent the 10 decimal digits. Since 4
bits may have up to 16 different binary combinations, a total of 6
combinations will be unused.

The position weights of the BCD code are 8, 4, 2, 1. Other codes


(shown in the table) use position weights of 8, 4, -2, -1 and 2, 4, 2, 1. An
example of a non-weighted code is the excess-3 code where digit codes is
obtained from their binary equivalent after adding 3. Thus the code of a
decimal 0 is 0011, that of 6 is 1001, etc.
Error detecting & error correcting codes:

When a message is transmitted, it has the potential to get scrambled


by noise. This is certainly true of voice messages, and is also true of the
digital messages that are sent to and from computers. Now even sound and
video are being transmitted in this manner. By a digital message, we mean a
sequence of 0's and 1's which encodes a given message. What we will seek
to do is to add more data to a given binary message that will help to detect if
an error has been made in the transmission of the message; adding such
data is called an error-detecting code.
We will also try to add data to the original message so that we can
detect if errors were made in transmission, and also to figure out what the
original message was from the possibly corrupt message that we received.
This type of code is an error-correcting code.

A common type of error-detecting code is called a parity check. For


example, consider the message 1101. We add a 0 or 1 to the end of this
message so that the resulting message has an even number of 1's. We would
thus encode 1101 as 11011. If the original message were 1001, we would
encode that as 10010, since the original message already had an even
number of 1's. Now consider receiving the message 10101. Since the
number of 1's in this message is odd, we know that an error has been made
in transmission.
However, we do not know how many errors happened in transmission
or which digit(s) were affected. Thus a parity check scheme detects errors,
but does not locate them for correction.

Parity Checking:
One simple way to detect errors is:
1. Count the number of ones in the binary message.
2. Append one more bit, called the parity bit, to the message.
3. Set the parity bit to either 0 or 1, so that the number of ones in the
result is even. For example, if the original message contained 17 ones, the
parity bit would be a one; if there had been 16 ones, the parity bit would be
a zero.
4. Count the number of ones in the received message, including the
parity bit. The result will always be even if no errors were encountered. (This
approach also works if the parity bit is set to make the count come out odd,
as long as the receiver checks for an odd count.)

This simple check does have two limitations: it only detects errors,
without being able to correct them; and it can’t detect errors that invert an
even number of bits.

Error-Detection Codes:
Binary information may be transmitted through some communication
medium, e.g. using wires or wireless media. A corrupted bit will have its
value changed from 0 to 1 or vice versa. To be able to detect errors at the
receiver end, the sender sends an extra bit (parity bit) with the original
binary message.
A parity bit is an extra bit included with the n-bit binary message to
make the total number of 1’s in this message (including the parity bit) either
odd or even. If the parity bit makes the total number of 1’s an odd (even)
number, it is called odd (even) parity.

The table shows the required odd (even) parity for a 3-bit message.

At the receiver end, an error is detected if the message does not


match have the proper parity (odd/even). Parity bits can detect the
occurrence 1, 3, 5 or any odd number of errors in the transmitted message.
No error is detectable if the transmitted message has 2 bits in error
since the total number of 1’s will remain even (or odd) as in the original
message. In general, a transmitted message with even number of errors
cannot be detected by the parity bit.

You might also like