#include<bits/stdc++.h>
using
namespace
std;
typedef
union
{
float
f;
struct
{
unsigned
int
mantissa : 23;
unsigned
int
exponent : 8;
unsigned
int
sign : 1;
} raw;
} myfloat;
unsigned
int
convertToInt(unsigned
int
* arr,
int
low,
int
high)
{
unsigned
int
f = 0, i;
for
(i = high; i >= low; i--) {
f = f + arr[i] *
pow
(2, high - i);
}
return
f;
}
int
main()
{
unsigned
int
ieee[32]
= { 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0 };
myfloat var;
unsigned
int
f = convertToInt(ieee, 9, 31);
var.raw.mantissa = f;
f = convertToInt(ieee, 1, 8);
var.raw.exponent = f;
var.raw.sign = ieee[0];
cout <<
"The float value of the given"
" IEEE-754 representation is : \n"
;
cout << fixed << setprecision(6) << var.f <<endl;
return
0;
}