0% found this document useful (0 votes)
2 views63 pages

Understanding Computer Data Representation

Computer System Architecture encompasses the design and structure of computer systems, detailing how hardware components are organized and interact, as well as how software controls them. It includes the representation of data in various number systems such as binary, decimal, octal, and hexadecimal, and methods for converting between these systems. Additionally, it covers fixed-point and floating-point representations, complements for negative numbers, and the handling of overflow in arithmetic operations.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views63 pages

Understanding Computer Data Representation

Computer System Architecture encompasses the design and structure of computer systems, detailing how hardware components are organized and interact, as well as how software controls them. It includes the representation of data in various number systems such as binary, decimal, octal, and hexadecimal, and methods for converting between these systems. Additionally, it covers fixed-point and floating-point representations, complements for negative numbers, and the handling of overflow in arithmetic operations.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

UNIT 1

What is Computer System Architecture?

It is the conceptual design and logical structure of a computer


system, describing how hardware components are organized,
how they interact, and how software controls them.

It explains how a computer is built internally and how it processes


information

In short It is the study of the structure, behavior, and design of


computers.
Computer Data Representation
 Computer Data Representation refers to the way data is
stored, processed, and interpreted inside a computer
system.

 Since computers understand only binary (0s and 1s), all


kinds of information numbers, text, images, audio, and
instructions are converted into binary codes.
Basic Computer Data
Types
(1) Numbers used in arithmetic computations.
Integer numbers and Fractional numbers
(2) Letters of the alphabet used in data processing.
Uppercase letters, Lowercase letters, Digits as characters and
Symbols.
(3) Other discrete symbols used for specific purposes.
Punctuation, Mathematical symbols and Control codes
Number System
Radix
Radix is the base of a number system, specifying the number of
unique digits it uses. For example, the decimal system has a radix of
10 because it uses 10 digits (0-9), while the binary system has a
radix of 2 because it uses two digits (0 and 1).
Decimal Number System (Base 10)
The decimal number system, or base-10 system, is the standard
way we count, using ten unique digits (0-9) where each digit's
value depends on its position as a power of ten (ones, tens,
hundreds, etc.).
Uses 10 digits:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Example: 724.5
Binary Number System (Base 2)
The binary number system is a base-2 system that uses only two
digits, 0 and 1, to represent numbers.

Uses only two digits: 0 and 1

Example: (101101)₂
Octal Number System (Base 8)
The octal number system is a base-8 positional system using digits
0-7, where each position's value is a power of 8 (like 8⁰, 8¹, 8², etc.)
Uses digits:
0-7

Example:
Hexadecimal Number System (Base 16)
The hexadecimal number system (base-16) uses 16 unique
symbols (0-9 and A-F) to represent numbers, where A=10, B=11,
C=12, D=13, E=14, and F=15
Uses 16 symbols:
0 - 9, A, B, C, D, E, F

Example: (F3)₁₆
Binary to Decimal, Octal, Hexadecimal
Binary to Decimal

Method:
Multiply each bit by powers of 2 and add.

Example:
Binary to Octal

Method:
Group bits in sets of 3 from right to left.

Example:
Binary to Hexadecimal

Method:
Group bits in sets of 4 from right to left.

Example:
Decimal to Binary, Octal, Hexadecimal
Decimal to Binary
Method:
Repeated division by 2 (remainders read bottom to
top).
Example:
Decimal to Octal

Method:
Repeated division by 8.

Example:
Decimal to Hexadecimal

Method:
Repeated division by 16.

Example:
Octal to Binary, Decimal, Hexadecimal
Octal to Binary
Method:
Replace each octal digit with 3-bit binary.

Example:
Octal to Decimal

Method:
Multiply digits by powers of 8.

Example:
Octal to Hexadecimal

Method:
Octal to Binary to Hexadecimal.

Example:

Group in 4 bits:
Hexadecimal to Binary, Decimal, Octal
Hexadecimal to Binary
Method:
Replace each hex digit with 4-bit binary.

Example:
Hexadecimal to Decimal

Method:
Multiply digits by powers of 16.

Example:
Hexadecimal to Octal

Method:
Hexadecimal to Binary to Octal.

Example:
=
Group in 3 bits:
Quick Summary

Hexadecim
From \ To Binary Decimal Octal
al
Binary — Powers of 2 Group 3 bits Group 4 bits
Decimal Divide by 2 — Divide by 8 Divide by 16
3-bit
Octal Powers of 8 — Via binary
mapping
Hexadecim 4-bit
Powers of 16 Via binary —
al mapping
Decimal Representation
• Binary conversion of a decimal number gives its true binary value
Example:
(99)₁₀ = (1100011)₂
• BCD representation encodes each decimal digit separately
Example:
(99)₁₀ = 1001 1001 (BCD)
Decimal Binary BCD
50 110010 0101 0000
99 1100011 1001 1001
248 11111000 0010 0100 1000
Alphanumeric Representation

Many computer applications require handling not only numbers


but also letters and special symbols. Such data is called
alphanumeric data.

Alphanumeric Character Set


An alphanumeric character set includes:
• 10 decimal digits (0–9)
• 26 alphabet letters (A–Z / a–z)
• Special characters such as + , − , = , $
ASCII Code
The most widely used alphanumeric code is ASCII
(American Standard Code for Information Interchange).
Complements
Complements are methods used in computer systems to represent
negative numbers and to simplify arithmetic operations, especially
subtraction. Instead of performing subtraction directly, computers
convert it into addition using complements, which is easier to
implement in hardware.

For a number system with base r, there are two types of


complements:
•(r − 1)’s complement
•r’s complement
[Link] subtraction
• Subtraction is performed as addition using complements.
• No separate subtraction hardware required.
2. Single representation of zero (2’s complement)
• Avoids confusion of +0 and −0 (unlike 1’s complement).
3. Efficient arithmetic operations
• Addition, subtraction, and multiplication become easier.
• Reduces hardware complexity.
4. Automatic sign handling
• Sign bit is handled naturally during operations.
5. Widespread usage
• 2’s complement is used in almost all modern computers.
(r − 1)’s Complement
The (r − 1)’s complement of a number in base r is obtained by
subtracting each digit of the number from (r − 1).
• It is mainly used in representing negative numbers and
performing subtraction.
• Different number systems have different (r − 1)’s complements.
9’s Complement (Decimal)
• Used in the decimal number system (base 10).
• Obtained by subtracting each digit from 9.
Example: 9’s complement of 346 = 653
1’s Complement (Binary)
• Used in the binary number system (base 2).
• Obtained by changing all 1s to 0s and 0s to 1s.
Example: 1’s complement of 10101 = 01010
r’s Complement
• The r’s complement of a number in base r is obtained by adding
1 to its (r − 1)’s complement.
• It is widely used in computers to represent negative numbers
and to perform subtraction using addition, which simplifies
hardware design.
10’s Complement (Decimal)
• Used in the decimal number system (base 10).
• Obtained by adding 1 to the 9’s complement of a number.
• Helps in performing decimal subtraction by converting it into
addition.
Example: 10’s complement of 346 = 653 + 1 = 654
2’s Complement (Binary)
• Used in the binary number system (base 2).
• Obtained by adding 1 to the 1’s complement of a binary number.
• It is the most commonly used method for representing negative
numbers in computers.
Example: 2’s complement of 10101 = 01010 + 1 = 01011
Fixed-Point Representation
In fixed-point representation, the binary point is at a fixed position
in the number. This allows the computer to treat the number
consistently as either an integer (binary point at the right) or a
fraction (binary point at the left). It is simple to implement and is
commonly used for numbers where precision and range are known
in advance.
1. Simple hardware design
• Requires less complex circuitry than floating-point.
• Faster arithmetic operations.
2. High speed
• Addition, subtraction, and multiplication are faster.
• Suitable for real-time systems and embedded devices.
3. Low memory usage
• Uses fewer bits compared to floating-point.
• Efficient storage.
4. Predictable precision
• Decimal point is fixed, so precision is known and consistent.
5. Cost-effective
• No floating-point unit (FPU) required.
• Used in microcontrollers and DSP systems.
Unsigned Fixed-Point Representation
• Used to represent only non-negative numbers (0 and positive
values).
• No sign bit is used.
• All bits represent the magnitude of the number.
• Binary point position is fixed (usually at the right for integers).

Range (n bits) :
Signed Fixed-Point Representation
• Used to represent both positive and negative numbers.
• The leftmost bit is the sign bit: 0 as Positive and 1 as Negative
• Remaining bits represent the magnitude.
• Negative numbers are usually stored using 2’s complement.

Types of signed fixed point representation


1. signed-magnitude representation 1 0001110
2. signed-1's complement representation 1 1110001
3. signed-2's complement representation 1 1110010
Signed-Magnitude Representation
In signed-magnitude representation, the leftmost bit is the sign bit
and the remaining bits represent the magnitude (absolute value) of
the number.
Sign bit = 0 as Positive number
Sign bit = 1 as Negative number
The magnitude bits are the same as the binary value of the number.
This method is simple and easy to understand.
Signed 1’s Complement Representation
Signed 1’s complement representation is a way to represent
positive and negative fixed-point numbers in binary.
The leftmost bit is the sign bit
• 0 as Positive number
• 1 as Negative number
• A positive number is stored as its normal binary value.
• A negative number is obtained by inverting (flipping) all bits of
the corresponding positive number.
Signed 2’s Complement Representation
• Most widely used method in computers.
• Negative numbers are formed by:
Taking 1’s complement
Adding 1
• Only one zero, simplifies arithmetic.
Arithmetic operations:
Addition and subtraction using 2’s complement
Addition
Subtraction
Decimal Fixed-Point Representation
In decimal fixed-point representation, negative numbers are
stored using the 10’s complement.

This method is similar to 2’s complement in binary.

Key Rules
• Positive number : stored as it is (sign digit = 0)
• Negative number : stored in 10’s complement form
• Addition rule : add all digits (including sign digit) and discard
the end carry
Consider the addition (+375) + (-240) = +135
done in the signed10's complement system.
Why This Works
• Negative numbers are stored in 10’s complement
• Addition is done like normal decimal addition
• End carry is discarded, just like in 2’s complement binary
arithmetic
• This avoids separate subtraction hardware

Key Points
• 10’s complement is used for signed decimal arithmetic
• BCD stores each decimal digit in 4 bits
• Addition includes sign digit
• End carry is discarded
• Similar logic to 2’s complement in binary
Overflow
What is Overflow?
Overflow occurs when the result of an arithmetic operation exceeds
the range that can be represented with the given number of bits in
a register.
• If a register has n bits, it can store only n-bit results
• If the result needs n + 1 bits, overflow occurs
Overflow in Unsigned Numbers
• Overflow is detected by the carry out of the most significant bit
(MSB)
Example (8-bit unsigned)
11110000 (240)
+
00110000 (048)
---------------------
1 00100000 (288)
• Result = 288 (needs 9 bits)
• The leftmost carry = 1
Overflow in Signed (2’s Complement) Numbers
Range of 8-bit signed numbers
• −127 to +127

Important Rule
Overflow occurs only when:
• Both numbers are positive, and result is negative
• OR both numbers are negative, and result is positive

Overflow never occurs when:


• One number is positive and the other is negative
Positive Overflow

Add +70 and +80 (8-bit signed)

+70 = 01000110
+80 = 01010000
----------------
10010110

Expected result: +150

Actual result sign bit = 1 (negative)


Negative Overflow

Add −70 and −80

−70 = 10111010
−80 = 10110000
----------------
1 01101010

Expected result: −150

Result became positive


What to Do After Overflow Occurs ?
1. Detect the Overflow
• The computer sets an overflow flag (flip-flop).
• This flag tells the system that the result is invalid.
• For signed numbers, overflow is detected when:
• Carry into the sign bit ≠ Carry out of the sign bit.
2. Discard the Incorrect Result
• The value stored in the register cannot be trusted.
• Example (8-bit signed):
• (+70 ) + (+80) = +150 (overflow)
• Stored result becomes negative as a wrong
3. Special Case: Unsigned Numbers
• Overflow detected using carry-out bit.
• Carry is usually:
• Stored separately or
• Used in multi-precision arithmetic.
4. Take Corrective Action (System Dependent)
a) Generate an Error / Exception
• Most computers raise an overflow exception.
• Program execution may stop.
• Used in critical systems (banking, scientific computing).
b) Ignore Overflow (Wrap Around)
• Some systems ignore overflow.
• Result “wraps around” due to limited bits.
• Common in low-level or embedded systems.
c) Use Larger Word Size
• Switch from 8-bit as 16-bit as 32-bit registers.
• Prevents overflow by increasing range.
d) Software Handling
• Program checks overflow flag.
• Takes action like: Recalculating, Displaying warning and Saturating value to max/min
Situation Action Taken
Overflow detected Set overflow flag
Result incorrect Discard or ignore
High-level systems Raise error/exception
Embedded systems Wrap around
Need accuracy Use larger data size
Floating-Point Representation
Why Floating-Point Representation is Needed
In fixed-point representation, the binary/decimal point is fixed.
This causes problems when:
• Numbers are very large (e.g., 6,500,000)
• Numbers are very small (e.g., 0.0000123)
Floating-point representation solves this by allowing the decimal
(or binary) point to “float”.
This is similar to scientific notation used in mathematics.
[Link] (Fraction)
• A signed fixed-point number
• Contains the significant digits of the number
[Link]
• Indicates the position of the decimal (or binary) point
• Specifies how much the mant radix point should be shifted
The number is interpreted as:
where
• m = mantissa
• r = radix (10 for decimal, 2 for binary)
• e = exponent
Decimal Big number: +6132.789
It can be written as:

Mantissa = 0.6132789
Exponent = +4

Decimal Small number: +


Floating-point form:

Mantissa = 4.5
Exponent = −5
Binary Big number: +1001.11₂
It is represented as:

Mantissa =
Exponent = +4

Binary Small number:


Normalize it:

Mantissa = 1.01₂
Exponent = −4
Normalization
A floating-point number is normalized if the leftmost digit of the
mantissa is non-zero.
• Normalization increases precision
• If leading zeros exist, the mantissa is shifted left and the exponent
is adjusted accordingly
• Zero cannot be normalized and is stored as all zeros
Why normalization is needed
• Leading zeros in the mantissa waste storage bits.
• Normalization shifts the mantissa so that its most significant digit
is non-zero.
• The exponent is adjusted to keep the actual value unchanged.
Decimal normalization
Number: 350
Unnormalized form:

Normalized form:

Here:
Mantissa = 3.5 (non-zero leftmost digit)
Exponent = 2
Binary normalization
Binary number:

Normalized form:

Here:
Mantissa = 1.101 (non-zero leftmost digit)
Exponent = 2
1. Very large range
• Can represent extremely large and very small numbers.
• Suitable for scientific and engineering calculations.
2. Automatic scaling
• Decimal point “floats” based on exponent.
• No need for manual scaling.
3. High precision for real numbers
• More accurate representation of fractions.
• Reduces rounding errors compared to fixed-point.
4. Standardized format
• IEEE-754 standard ensures portability across systems.
5. Essential for complex computations
• Used in simulations, graphics, AI/ML, and scientific applications.
Feature Fixed-Point Floating-Point
Variable (stored using
Binary point position Fixed (assumed)
exponent)
Components Single register Mantissa + Exponent
Range of values Limited Very large
Arithmetic Simple and fast Complex and slower
Hardware complexity Simple Complex
Overflow Frequent Rare
Embedded systems, Scientific, engineering
Use cases
business apps calculations
Example 00001101 as 13 0.6132789 × 10⁴

You might also like