You are on page 1of 18

GROUP 4

OPERATIONS ON
DATA
INTRODUCTION
In this chapter, we show how to operate on data stored in a computer. Operations on data can be divided into three broad
categories: logic operations, shift operations, and arithmetic operations.

LOGIC OPERATIONS SHIFT OPERATIONS ARITHMETIC OPERATIONS


• Logic operations at bit level • Simple shift • Arithmetic operations on integers
• Logic operations at pattern • Arithmetic operations on reals
• Circular shift
level
• Arithmetic shift
operations
LOGIC OPERATIONS
LOGIC OPERATIONS AT BIT LEVEL

• NOT: Đảo ngược giá trị của một bit.

• AND: Trả về 1 khi cả hai bit đều là 1.

• OR: Trả về 1 khi ít nhất một trong hai bit là 1.

• XOR: Trả về 1 khi hai bit khác nhau, và 0 khi giống nhau.
Logic operations at bit level

Figure 4.1 Logic operations at the bit level


LOGIC OPERATIONS AT PATTERN LEVEL
Figure 4.2 shows these four operators with input and output patterns

Figure 4.2 Logic operators applied to bit patterns


Logic operations at pattern level
Example: Use the NOT operator on the bit pattern 10011000.

Example: Use the AND operator on the bit patterns 10011000 and 00101010.
Logic operations at pattern level
Example: Use the OR operator on the bit patterns 10011001 and 00101110.

Example: Use the XOR operator on the bit patterns 10011001 and 00101110.
Logic operations at pattern level

Applications: Four logic operations can be used to modify a bit pattern.


Unsetting specific bits Setting specific bits

Flipping specific bits


SHIFT OPERATIONS
SHIFT OPERATIONS
Simple shift

Figure 4.3 shows the simple right shift and simple left shift operations for an 8-bit
pattern
SHIFT OPERATIONS
Circular shift

Figure 4.4 shows the circular shift left and circular shift right operation
SHIFT OPERATIONS
Arithmetic shift operations

. Figure 4.5 shows these two operations.


ARITHMETIC
OPERATIONS
ARITHMETIC OPERATIONS
Arithmetic operations on integers

• Addition and subtraction for two’s complement integers


ARITHMETIC OPERATIONS
EXAMPLE:
ARITHMETIC OPERATIONS
Arithmetic operations on reals

• Tất cả các phép toán số học như cộng, trừ, nhân và chia đều có thể được áp dụng cho các số thực được lưu trữ trong định
dạng dấu chấm động (floating-point)
• Phép nhân của hai số thực liên quan đến phép nhân của hai số nguyên trong biểu diễn dấu và giá trị tuyệt đối
• Phép chia của hai số thực cũng liên quan đến phép chia của hai số nguyên trong biểu diễn dấu và giá trị tuyệt đối
THANK YOU!

You might also like