DBMS

Wednesday, October 2, 2019

Biwise Shifting Techniques and Data Conversion Formats

Arithmetic Shift Vs. Logical Shift

Arithmetic Shift operates on the data, it considers data as signed integer and does not shift the signed bit. (in both cases: either left or right shift)
In case of logical shift, sign of the data is not important, and data is shifted left of right without worring about the sign.

Impact

If during shift operation, overflow occurs then both arithmetic and logical shift may produce different results i.e. arithmetic shift do not allow overflow but the logical shift allows to occur.
Example
Before shift data is
10101001
After 1 bit logical left shift
01010010    #sign changed
After 1 bit arithmetic left shift
11010010    #sign unchanged

Rotation or Cyclic Shift

In the cylic shift, each bit is rotated (depending upon left or right rotation) without loosing the bits. In this process each bit can come at the sign bit location (LSB) which helps to identify the sign of the data.
Every shift operation is performed by ALU with the help of the transfer instructions.

Conversion into Binary Coded Decimal (BCD) Format

In BCD Conversion, each decimal digit is converted into four bits. It is send in Packed Decimal or Unpacked Decimal Format. The digit 0 is converted into 0000, 1 as 0001, ...,9 is represented as 1001. BCD convertion takes equal to or more number of bits than a normal binary conversion. In Packed decimal 8 bits are transferred with bad at 4 LSBs and few unimportant bits at MSBs, whereas in packed decimal, two numbers are simultaneously managed at 4 LSBs and 4 MSBs.

Conversion into International Reference Alphabet (IRA) Format

In IRA conversion, each decimal number is represented in four bits considering 011 as prefix. so 0 is represented as 0110000, and 9 is represented as 0111001.

Conversion into American Standard Code for Information Interchange (ASCII) Format

For ASCII conversion, each character is given 7 bit code. The most significant bit is filled with o or 1 depending upon the type of parity (even or odd parity) maintained for data transfer.

Conversion into Extended Binary Coded Decimal Interchange Code (EBCDIC) Format

Similar to IRA coding, EBCDIC coding also converts each and every bit in four bits. The only difference is, it use 1111 as prefix, i.e. 0 is represented as 11110000 and 9 is represented as 11111001.

No comments:

Post a Comment