Unit 1: Number System & Logic Gates: UE20EC205 Notes
Unit 1: Number System & Logic Gates: UE20EC205 Notes
Notes
Decimal Numbers:
• Each column of a decimal number has ten times the weight of the previous column.
• From right to left, the column weights are 1, 10, 100, 1000, and so on.
• Decimal numbers are referred to as base 10. The base is indicated by a subscript after
the number to prevent confusion when working in more than one base.
• For example, a three-digit decimal number represents one of 1000 possibilities in the
range of 0 to 999.
• Bits represent one of two values, 0 or 1, and are joined together to form binary
numbers.
• Each column of a binary number has twice the weight of the previous column, so binary
numbers are base 2.
• In binary, the column weights (again from right to left) are 1, 2, 4, 8, 16, 32, 64, 128,
256, 512, 1024, 2048, and so on.
Solution:
Solution:
• Two methods:
Method 1: Find the largest power of 2 that fits, subtract and repeat: (Left to right)
8410 64x1
84 - 64 = 20 16x1
20 - 16 = 4 4x1 = 10101002
8410 = 10101002
Method 2: Repeatedly divide by 2, remainder goes in next most significant bit (Do and
verify). (Right to left)
Hexadecimal Numbers:
• “Hexadecimal,” a term coined by IBM in 1963, derives from the Greek hexi (six) and
Latin decem (ten).
• Hexadecimal numbers use the digits 0 to 9 along with the letters A to F, as shown in
the following Table.
• Columns in base 16 have weights of 1, 16, 162 (or 256), 163 (or 4096), and so on.
Example: HEXADECIMAL TO BINARY AND DECIMAL CONVERSION
Solution:
so 2ED16 = 0010111011012.
Solution:
33310 = 14D16
• One hexadecimal digit stores one nibble and two hexadecimal digits store one full byte.
• Microprocessors handle data in chunks called words. The size of a word depends on
the architecture of the microprocessor.
Example:
Solution:
• Similarly, MB, Mb, GB, and Gb are used for millions and billions of bytes and bits.
• For example, the maximum speed of a dial-up modem is usually 56 kbits/sec (kbps).
Binary Addition:
• Digital systems usually operate on a fixed number of digits. Addition is said to overflow
if the result is too big to fit in the available digits.
• Several schemes exist to represent signed binary numbers; the two most widely
employed are called sign/magnitude and two’s complement.
Sign/Magnitude Numbers:
• An N-bit sign/magnitude number uses the most significant bit as the sign and the
remaining N−1 bits as the magnitude (absolute value).
Solution:
• Two’s complement numbers are identical to unsigned binary numbers except that the
most significant bit position has a weight of −2N-1 instead of 2N-1.
• The sign of a two’s complement number is reversed in a process called taking the two’s
complement.
• The process consists of inverting all of the bits in the number, then adding 1 to the least
significant bit position.
Example:
• Solution:
• 11012 + 1 = 11102.
• So −210 is 11102.
Example:
• Solution:
Example:
ADDING TWO’S COMPLEMENT NUMBERS
• Solution:
• The fifth bit is discarded, leaving the correct 4-bit result 00002.
Example:
• Subtraction is performed by taking the two’s complement of the second number, then
adding (please do it and verify) .
• Like unsigned numbers, N-bit two’s complement numbers represent one of 2 N possible
values.
• However the values are split between positive and negative numbers.
• In general, the range of an N-bit two’s complement number spans *−2N-1, 2N-1 − 1+.
• Adding two N-bit positive numbers or negative numbers may cause overflow if the
result is greater than 2N-1 − 1 or less than −2N-1 (i.e. the range)
• Unlike unsigned numbers, a carry out of the most significant column does not indicate
overflow.
• Instead, overflow occurs if the two numbers being added have the same sign bit and the
result has the opposite sign bit.
Example:
Solution:
• The result overflows the range of 4-bit positive two’s complement numbers, producing
an incorrect negative result.
• If the computation had been done using five or more bits, the result 01001 2 = 910
would have been correct.
• When a two’s complement number is extended to more bits, the sign bit must be copied
into the most significant bit positions. This process is called sign extension.
• For example, the numbers 3 and −3 are written as 4-bit two’s complement numbers
0011 and 1101, respectively.
• The three most commonly used binary number systems are unsigned, two’s
complement, and sign/magnitude.
• Following Table compares the range of N-bit numbers in each of these three systems.
• Two’s complement numbers are convenient because they represent both positive and
negative integers and because ordinary addition works for all numbers.