0% found this document useful (0 votes)
10 views10 pages

Unit 1: Number System & Logic Gates: UE20EC205 Notes

The document covers the fundamentals of number systems including decimal, binary, and hexadecimal, explaining their structure, conversion methods, and representation of values. It also discusses binary addition, signed binary numbers, and the two's complement method for representing negative numbers. Additionally, it highlights the importance of bytes and nibbles in computer memory and the concept of overflow in binary arithmetic.

Uploaded by

BUSHANA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views10 pages

Unit 1: Number System & Logic Gates: UE20EC205 Notes

The document covers the fundamentals of number systems including decimal, binary, and hexadecimal, explaining their structure, conversion methods, and representation of values. It also discusses binary addition, signed binary numbers, and the two's complement method for representing negative numbers. Additionally, it highlights the importance of bytes and nibbles in computer memory and the concept of overflow in binary arithmetic.

Uploaded by

BUSHANA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

UE20EC205

Notes

Unit 1: Number System & Logic Gates


Number systems:

Decimal Numbers:

• Decimal digits are joined together to form longer 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.

• An N-digit decimal number represents one of 10N possibilities: 0, 1, 2, 3, …, 10N − 1. This


is called the range of the number.

• 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.

• An N-bit binary number represents one of 2N possibilities: 0, 1, 2, 3,…, 2N − 1.


Table: Binary numbers and their decimal equivalent

Example: BINARY TO DECIMAL CONVERSION

Convert the binary number 101102 to decimal.

Solution:

Example: DECIMAL TO BINARY CONVERSION

Convert the decimal number 8410 to binary.

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).

• Writing long binary numbers becomes tedious and prone to error.

• A group of four bits represents one of 24 = 16 possibilities.

• Hence, it is sometimes more convenient to work in base 16, called hexadecimal.

• 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

Convert the hexadecimal number 2ED16 to binary and to decimal.

Solution:

To Binary: Referring to the table:

216 = 00102, E16 = 11102 and D16 = 11012,

so 2ED16 = 0010111011012.

Conversion to decimal requires the arithmetic shown below:

Example: BINARY TO HEXADECIMAL CONVERSION

Convert the binary number 11110102 to hexadecimal.

Solution:

Start reading from the right:

Hence 11110102 = 7A16

Example 1.5: DECIMAL TO HEXADECIMAL AND BINARY CONVERSION

Convert the decimal number 33310 to hexadecimal and binary.

Solution: Like decimal to binary conversion, decimal to hexadecimal conversion can be


done from the left or the right.

Xx162 + Yx161 + Zx160

33310 = 14D16

To convert from hexadecimal to binary: 14D16 = 1010011012.

Try 2nd method i.e. repeated division.

Bytes and Nibbles:

• A group of eight bits is called a byte. It represents one of 28 = 256 possibilities.

• The size of objects stored in computer memories is customarily measured in bytes


rather than bits.
• A group of four bits, or half a byte, is called a nibble. It represents one of 2 4 = 16
possibilities.

• 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.

ESTIMATING POWERS OF TWO:

• 210 = 1024 (or 1 kilo)

• similarly 220 is 1 million (or 1 mega) and

• 230 is 1 billion (or 1 giga).

Example:

Find the approximate value of 224 without using a calculator.

Solution:

Split the exponent into a multiple of ten and the remainder.

• 1024 bytes is called a kilobyte (KB).

• 1024 bits is called a kilobit (Kb or Kbit).

• Similarly, MB, Mb, GB, and Gb are used for millions and billions of bytes and bits.

• Memory capacity is usually measured in bytes.

• Communication speed is usually measured in bits/sec.

• For example, the maximum speed of a dial-up modem is usually 56 kbits/sec (kbps).

Binary Addition:

• Example: BINARY ADDITION

• Compute 01112 + 01012.


• Solution:

ADDITION WITH OVERFLOW:

• 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.

Example: Compute 11012 + 01012. Does overflow occur?

Solution: This result overflows the range of a 4-bit binary number.

Signed Binary Numbers:

• 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).

• A sign bit of 0 indicates positive and a sign bit of 1 indicates negative.

Example: SIGN/MAGNITUDE NUMBERS

Write 5 and −5 as 4-bit sign/magnitude numbers

Solution:

Both numbers have a magnitude of 510 = 1012.

Thus, 510 = 01012 and −510 = 11012.


Two’s Complement Numbers:

• 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.

• This is useful to find the representation of a negative number or to determine the


magnitude of a negative number.

Example:

TWO’S COMPLEMENT REPRESENTATION OF A NEGATIVE NUMBER

• Find the representation of −210 as a 4-bit two’s complement number.

• Solution:

• Start with + 210 = 00102.

• To get −210, invert the bits and add 1.

• Inverting 00102 produces 11012.

• 11012 + 1 = 11102.

• So −210 is 11102.

Example:

VALUE OF NEGATIVE TWO’S COMPLEMENT NUMBERS

• Find the decimal value of the two’s complement number 10012.

• Solution:

• 10012 has a leading 1, so it must be negative.

• To find its magnitude, invert the bits and add 1.

• Inverting 10012 = 01102.

• 01102 + 1 = 01112 = 710.

• Hence, 10012 = −710.

Example:
ADDING TWO’S COMPLEMENT NUMBERS

• Compute (a) −210 + 110 and

• (b) −710 + 710 using two’s complement numbers.

• Solution:

• (a) −210 + 110 = 11102 + 00012 = 11112 = −110.

• (b) −710 + 710 = 10012 + 01112 = 100002.

• The fifth bit is discarded, leaving the correct 4-bit result 00002.

Example:

• SUBTRACTING TWO’S COMPLEMENT NUMBERS

• Compute (a) 510 − 310 and

(b) 310 − 510 using 4-bit two’s complement numbers.

• 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.

• For example, a 4-bit unsigned number represents 16 values: 0 to 15.

• A 4-bit two’s complement number also represents 16 values: −8 to 7.

• 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)

• Adding a positive number to a negative number never causes overflow.

• 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:

ADDING TWO’S COMPLEMENT NUMBERS WITH OVERFLOW


Compute 410 + 510 using 4-bit two’s complement numbers. Does the result overflow?

Solution:

410 + 510 = 01002 + 01012 = 10012 = −710.

• 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.

Two’s Complement Numbers:

• 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.

• Similarly extend the sign for 7-bit two’s complement numbers.

Comparison of Number Systems:

• 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.

Table: Range of N-bit numbers


Number line and 4-bit binary encodings:

Figure: Number line and 4-bit binary encodings

You might also like