- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Representation of fractions
To represent fractions may be necessary quite often inside the computer. For example, it may be needed to represent inside a computer a value like +0.610 or -0.610. To represent signed fractions, it is necessary to assume the binary point just after the MSB in the bit sequence. Such numbers where the binary point is assumed to be at a fixed position in the bit sequence are called fixed-point numbers.
Unsigned fractions will have the assumed binary point at the extreme left. SM,1's complement, and 2's complement fractions will have this imaginary binary point just to the right of the MS bit.
If the imaginary point is at the extreme right, then the number is an integer. If the imaginary binary point is at the extreme left for an unsigned number, the number is an unsigned fraction. If the binary point is to the immediate right of the MS bit, the number is a signed fraction. If the binary point is in the middle of a bit sequence, the number has an integer and a fractional part.
Let us discuss on 2’s complement fractions. As an example, the value of 1 001, if the interpretation is that it is a 2's complement fraction will be as follows - It is 1.001 assuming the binary point after the MS bit. As the MS bit is 1, it is a negative number. Then the remaining bits do not specify the magnitude directly. The 2's complement of 1 001 is 0110+ 1 = 0 111. This is a positive fraction with the value 1 × 2−1 +1 × 2−2 +1 × 2−3 =0.5 + 0.25 + 0.125 = 0.875 decimal. Thus, -0.875 is the value of 1001.
If the word size is n bits, the smallest magnitude non-zero fraction that can be represented is 2(n-1). A table of word size and the smallest magnitude fraction that can be represented as shown in the following.
|Word size||Smallest magnitude 2 's complement fraction|
| 32||±0.5 × 10-9|
The minimum word size has to be 8 bits to represent the number -0.0123 somewhat accurately. The accuracy is very much improved if the word size is further increased.
- Python Rational numbers (fractions)
- Unique Fractions in C++
- Simplified Fractions in C++
- Representation of Graphs
- 2's complement fractions
- Matrix Representation of Graphs
- C Program to add two fractions
- Product of given N fractions in reduced form in C
- Representation of Relations using Graph
- Array Representation Of Binary Heap
- Program to compare two fractions in C
- Representation of class hierarchy in DBMS
- String representation of Boolean in Java