Converting bit patterns to IEEE 754 Single Precision equivalents
Converting bit patterns to IEEE 754 Single Precision equivalents
The IEEE 754 standard defines how floating point numbers are stored in binary form. In this tutorial we convert a bit pattern into its' base 10 equivalent.
Test Case
Given a 32bit base 2 number:
0100 0010 0010 1001 1110 0100 0000 0000_{2}
This bit pattern has no inherent encoding, but if we assume that it represents an IEEE 754 single precision number, we can convert it to base 10.
Sign
 Exponent (biased 127)
 Fraction (without the leading '1')


0
 100 0010 0
 010 1001 1110 0100 0000 0000

Calculate the exponent
Exponent = 128 + 4 = 132
Subtracting the bias of 127, we get 5. Therefore we will need to shift the fraction 5 places to the right.
Calculate the Fraction
Fraction = 1.010 1001 1110 0100 0000 0000_{ (base 2)}
The leading '1' is not stored in the original bit pattern. According to the IEEE 754 standard, a leading '1' is always assumed.
Apply the 'hidden' digit to the right of the radix point
One solution is 1.010 1001 1110 0100 0000 0000_{2} X 2^{5}
This solution is unwieldy since it is in base 2.
Apply the exponent to the fraction by sliding the radix point
Another solution is 1010 10.01 1110 0100 0000 0000
This solution is unwieldy since it is in base 2.
Convert the resulting bit pattern to powers of 2
Another solution is (2^{0}+2^{2}+2^{4}+2^{7}+2^{8}+2^{9}+2^{10}+2^{13}) * 2^{5}
Apply the exponent to the powers of 2
Another solution is (2^{5}+2^{3}+2^{1}+2^{2}+2^{3}+2^{4}+2^{5}+2^{8}) ^{}
Converting each position to base 10 and adding gives us:
32.
8.
2.
.25
.125
.0625
.03125
.00390625 ============
42.47265625
Therefore,
0100 0010 0010 1001 1110 0100 0000 0000_{2} converts to = 42.47265625_{10}
More by this Author
 19
We could nag, but this is better. It is less work for us to use the words of others to emphasize the importance of doing laundry. Besides, if you saw the way we dressed, you'd laugh your mouse off.
 EDITOR'S CHOICE12
Data Hiding is an aspect of Object Oriented Programming (OOP) that allows developers to protect private data and hide implementation details. In this tutorial we examine basic data hiding techniques in Java.
 EDITOR'S CHOICE5
A useful text editor is an essential component of any personal computer. Every day we need to make notes, compose documents, and record vital pieces of information. We depend on our text editor. Microsoft provided...