COA: Computer Organisation & Architecture Data Format

What is data format?

The binary representation of data values.

Why do we need to study?

#conceptBuilder

If you had done C/C++ programming in past or if not done then also no problem I'll tell you that there are some data types like int (for integers), char (for characters), float (for decimal numbers) etc. So we are giving the input in the format that we are understanding. But our computer can't understand these languages it only understands the machine language (binary language). So in our architecture, we have to do something to convert these to machine language and then the role of data format comes into the frame.

Classification of Data

In our syllabus, we only deal with Fixed-point and floating-point. And for characters, only we need to remember its name and full form for general knowledge point of view.
Now, getting started with Fixed Point.

Fixed point

Unsigned

In an unsigned fixed point, we simply convert the given number system to a binary number system. Generally, we only use to convert decimal to binary.

Example: (5) in binary is -

5/2        2      |    1    |
2/2        1      |    0    |    (from bottom to top)
1/2        0      |    1    |

Try it yourself

Convert (79) in binary.

Signed

In this type of representation, we are having two things or say two placeholders. One is for the sign bit, and another one is for magnitude. And hence we can represent both positive and negative values.

Format of Fixed-point Signed Representation

S is a signed bit, it is 0 for positive values & 1 for negative values.
M is for magnitude.

1. Signed Magnitude

Like if we have +5 then, for +, S is 0 and for 5, M is 101. So the representation of +5 is 0101. 
And for -5, S will be 1 and M will be as it is which is 101. So the representation of -5 is 1101. Then, this type of signed representation is called Signed Magnitude representation.

Try it yourself

What is the decimal value of 1111? If it is in signed representation.

2. 1's Complement

Now, in this representation, the method of representing positive quantity is the same as Signed Magnitude Representation. The only difference here is we take the Complement of positive value to get its negative.
Let's understand with an example like previous, suppose we have +5 its 1's complement representation will be 0101 (S is 0 and M is 101).
For, -5 we take the Complement of +5 in binary. For complement you only need to replace:

0 ----> 1
1 ----> 0

For -5 we take the Complement of 0101 so, it will be 1010 which is -5 in 1's complement representation.

Try it yourself

If 1110 is the number in 1's Complement representation. What will be the original number?

3. 2's Complement

For 2's complement representation also, the representation of positive values is the same as of signed magnitude and 1's complement representations. And for the negative value, we have to take the 2's complement of that positive value. And the resulting value is the negative of that value.
"DON'T WORRY! I WILL SHOW YOU HOW TO TAKE THE 2'S COMPLEMENT."
For 2's complement, first, take the 1's complement of the value and add 1 (Binary Addition) to that value. The resulting value will be the 2's complement.

2's Comp = 1's Comp + 1 (Binary Addition)

Let's continue the previous example, we have +5 in 2's complement representation it is 0101 (S is 0 and M is 101). 
For -5, we need to calculate its 2's Complement.

Step 1) get 1's complement of +5 = 1010
Step 2) Binary Addition of 1.          + 0001
Step 3) get 2's complement of - 5 = 1011

Try it yourself

If 1110 is the 2's Complement representation. Find its value?
We will answer all try yourself questions in our next post.
So, In this part we have covered:
  • what is data format?
  • Why do we need to study?
  • Classification of Data. And
  • A detailed discussion of fixed-point numerical data representation.

What's Next?

Next: Floating Point Representation
Afterwards: IEEE 754 Floating-Point Representation

Popular posts from this blog

How to install C Compiler and make VS Code ready for Getting Started with C

TOC: Theory of Computation | Syllabus, Marks Weightage and Important Chapters

Data Structure: Basic Introduction