Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views12 pages

Lecture 2 Number Systems

The lecture discusses number systems, focusing on complement operations used in digital computers for subtraction and logical manipulation. It explains diminished radix and radix complements, their definitions, and how they simplify subtraction processes. Additionally, it covers fixed-point and floating-point representations for storing real numbers, highlighting their advantages and limitations.

Uploaded by

cheesesaga.tl
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)
9 views12 pages

Lecture 2 Number Systems

The lecture discusses number systems, focusing on complement operations used in digital computers for subtraction and logical manipulation. It explains diminished radix and radix complements, their definitions, and how they simplify subtraction processes. Additionally, it covers fixed-point and floating-point representations for storing real numbers, highlighting their advantages and limitations.

Uploaded by

cheesesaga.tl
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/ 12

BACSE103 Computation Structures

Lecture 2: Number Systems


Dr. Anis Fatema
Assistant Professor Senior,
Sensors and Biomedical Department, SENSE.

24-07-2025 Lecture 2 1
Complements of numbers
• Complement operations are run on a single number in any given base
• Complements are used in digital computers to simplify the
subtraction operation and for logical manipulation
• Simplifying operations leads to simpler, less expensive circuits to
implement the operations
• There are two types of complements for each base‐r system:
1. The radix complement [r’s complement] – called the 10’s
complement in decimal, 2’s complement in binary and so on
2. The diminished radix complement [(r-1)’s complement] – called the
9’s complement in decimal, 1’s complement in binary and so on

24-07-2025 Lecture 2 2
Diminished radix complement
• Given a number N in base r having n digits, the (r - 1)’s complement of
N , i.e., its diminished radix complement, is defined as 𝑟 𝑛 − 1 − 𝑁
• For decimal numbers, the 9’s complement of N is 10𝑛 − 1 − 𝑁
• In this case, 10𝑛 − 1 is a number represented by n 9s
• For example, if n = 4, we have 104 = 10,000 and 104 - 1 = 9999
• It follows that the 9’s complement of a decimal number is obtained by
subtracting each digit from 9
• Examples:
• 1242
• 9981

24-07-2025 Lecture 2 3
Diminished radix complement
• For binary numbers, the 1’s complement of N is (2𝑛 −1) − 𝑁.
• Again, (2n – 1) is a binary number represented by n 1s
• For example, if n = 4, we have 24 = (10000)2 and 24 - 1 = (1111)2. Thus, the 1’s
complement of a binary number is obtained by subtracting each digit from 1
• However, when subtracting binary digits from 1, we can have either 1 - 0 = 1 or 1 -
1 = 0, which causes the bit to change from 0 to 1 or from 1 to 0, respectively
• Therefore, the 1’s complement of a binary number is formed by changing 1’s to
0’s and 0’s to 1’s.
• Examples:
• 11100101
• 10000

24-07-2025 Lecture 2 4
Radix complement
• The r’s complement of an n‐digit number N in base r is defined as 𝑟 𝑛 − 𝑁
for 𝑁 ≠ 0 and as 0 for 𝑁 = 0
• Comparing with the (r - 1)’s complement, we note that the𝑛r’s complement
is obtained by adding 1 to the (r - 1)’s complement, since 𝑟 − 𝑁 = [(𝑟 𝑛 −
1) − 𝑁] + 1
• Thus, the 10’s complement of decimal 2389 is 7610 + 1 = 7611 and is
obtained by adding 1 to the 9’s complement value
• The 2’s complement of binary 101100 is 010011 + 1 = 010100 and is
obtained by adding 1 to the 1’s‐complement value
• Examples:
• (66772)10
• (10011)2

24-07-2025 Lecture 2 5
Subtraction with Radix complements
• The usual method of borrowing taught in elementary school for subtraction is
less efficient when subtraction is implemented with digital hardware
• Lets assume we have to perform M-N in base r
• Here is the algorithm using Radix complement:
1. Take radix complement of N: 𝑟 𝑛 − 𝑁
2. Add this to M: 𝑟 𝑛 − 𝑁 + 𝑀 = 𝑟 𝑛 + 𝑀 − 𝑁 = 𝑟 𝑛 − (𝑁 − 𝑀)
3. If you get a carry in the (n+1)th digit, then the result is positive, discard the carry and you
are done
4. If you do not get a carry in the (n+1)th digit, then the result is negative. Take the radix
complement of the number to get the answer, then put a negative sign
• 10’s complement subtraction:
• (9812)10 – (3142)10
• (1423)10 – (7336)10

24-07-2025 Lecture 2 6
Subtraction with Diminished radix
complements
• The usual method of borrowing taught in elementary school for
subtraction is less efficient when subtraction is implemented with digital
hardware
• Lets assume we have to perform M-N in base r
• Here is the algorithm using Diminished radix complement:
1. Take diminished radix complement of N: 𝑟 𝑛 − 1 − 𝑁
2. Add this to M: 𝑟 𝑛 − 1 − 𝑁 + 𝑀 = 𝑟 𝑛 + 𝑀 − 𝑁 − 1 = (𝑟 𝑛 − 1) − (𝑁 − 𝑀)
3. If you get a carry in the (n+1)th digit, then the result is positive, add the carry to the
result and you are done
4. If you do not get a carry in the (n+1)th digit, then the result is negative. Take the
diminished radix complement of the number to get the answer, then put a
negative sign

24-07-2025 Lecture 2 7
Subtraction using complements

24-07-2025 Lecture 2 8
Binary subtraction with complements
• Perform the following subtractions using 2’s complement method:
• (110001)2 – (010100)2
• (010110)2 – (100)2
• (10)2 – (100000)2
• (100001)2 – (110100)2

• Perform the following subtractions using 1’s complement method:


• (110001)2 – (010100)2
• (100100)2 – (011101)2
• (1)2 – (10100)2
• (11010)2 – (110111)2

24-07-2025 Lecture 2 9
Representing fractions (real numbers)
• We need to operate with fractions all the time
• This means we need a method to store/represent them in binary
• The simplest way is to have a “fixed” point representation where the binary
point is assumed to be fixed at a certain location
• For example, for an 4-bit system, if given fixed-point representation is II.FF,
then you can store minimum value is 00.01 (0001) and maximum value is
11.11 (1111)
• Remember the point is not actually stored – it is assumed to be there
• There are three parts of a fixed-point number representation: the sign
field, integer field, and fractional field – which means we can also have
signed magnitude fixed point numbers and signed complement fixed point
numbers

24-07-2025 Lecture 2 10
Fixed point representation
• The advantage of using a fixed-point
representation is performance and ease
of arithmetic
• The disadvantage is relatively limited
range of values that they can represent
• So, it is usually inadequate for
numerical analysis as it does not allow
enough numbers and accuracy
• For instance, using 32-bit format: the 1
bit sign bit, 15 bits for integer, and 16
bits for the fractional part, the smallest
positive number is 2-16 ≈ 0.000015, and
the largest positive number is ≈ 32768
24-07-2025 Lecture 2 11
Floating point representation (IEEE Standard 754 Floating point)
• This representation does not reserve a specific
number of bits for the integer part or the fractional
part
• Instead it reserves a certain number of bits for the
number (called the mantissa) and a certain number
of bits to say where within that number the −53.5=(−110101.1)2=(−1.101011)x25
decimal place sits (called the exponent)
• We convert the number to be stored as 𝑁 = 𝑀 ∗ 𝑟 𝑒
and store M and e as binary
• Clearly, a large mantissa and small exponent can
give both high precision and high range
• The exponent field needs to represent both
positive and negative exponents. To do this, a bias
is added to the actual exponent in order to get the
stored exponent
• For instance, using 32-bit format: the 1 bit sign bit,
8 bits for signed exponent, and 23 bits for the
fractional part. Smallest is 1.18x10-38 and the
largest is 3.40x1038

24-07-2025 Lecture 2 12

You might also like