Arithmetic Operations
Arithmetic Operations
Presented By
Md. Ashiqur Rahman
Assistant Professor
Department of CSE,BUBT
Logical Shift
A logical shift is a bitwise operation that shifts the bits of a binary number to the left or
right.
Logical shifts are used for moving bits within a binary number without regard for the
number's sign or value
In a left logical shift, bits are moved to the left, filling the vacant bits with zeros. In a right
logical shift, bits are moved to the right, and the leftmost bits are filled with zeros.
Arithmetic shifts are used in signed number representation to maintain the number's sign
during shifting.
In a right arithmetic shift, the leftmost bit (the sign bit) is duplicated to fill the vacant bits,
preserving the sign of the number.
It's a common source of error in numerical computations, and precautions are taken to
minimize it.
Example: Subtracting 5.99999999 from 6.0 results in 0.00000001, where most of the
significant digits have canceled each other out.
It's a common operation in numerical approximations and rounding to make numbers more
manageable.
Example: Rounding 3.789 to two decimal places results in 3.79, where the trailing digit (9) is
lost.
• It's a critical error condition in computer systems and must be handled to avoid incorrect
results.
Example: In a 8-bit signed integer, adding 127 and 2 will result in overflow because the
result (129) cannot be represented in 8 bits.