#include
#include
# include "math. H"
#include
#include
using namespace std;
Void fun (bool m)/print/
{
Cout
Vector
{
Vector
for (int i=0; i<32. I++)
{
If (((a) (int) & amp; (0 x80000000 & gt;> I)))
{
X.p ush_back (1);
}
The else
{
X.p ush_back (0);
}
}
///////////////////////////////////print the hex binary code
Cout<& lt;" Binary code: "& lt;
Cout
return x;
}
Int get_hex_jiema (vector
{
//the original 1-8 bits of binary code to frameshift container
Vector
Vector
Unsigned int sum=0;
//calculation decimal number of binary code
for(int i=0; i<8; I++)
{
Sum=sum + (* ite) * pow (2, 7 - I);
Ite++;
}
Int jiema=sum - 127;
Return jiema;
}
Float get_10dec (vector
{
//save the integer part of binary, one of the initial value 1, size for the tail implied a
Vector
Vector
//original binary code to 9 - the tail to tail yards container
Vector
//according to size of exponent, shift to the left tail code, get the integer binary code
Zhengshu. Insert (zhengshu. End (), weima. The begin (), weima. The begin () + get_hex_jiema (a));
//the rest of the tail code for decimal binary code
Xiaoshu. Insert (xiaoshu. End (), weima. The begin () + get_hex_jiema (a), weima. The end ());
//////////////////////////////////////////
//print an integer and fractional part of binary code
Cout<& lt;" The integer part, "& lt;
Cout
Cout
Float zheng_shu=0;
Float xiao_shu=0;
Float sum=0;
//calculate the decimal integer sizes
For (int I=zhengshu. The size (); i> 0; I -)
{
Zheng_shu=zheng_shu + zhengshu pow [I - 1) * (2, zhengshu. The size () - I);
}
//calculate the decimal decimal size
for(int i=0; i
Xiao_shu=xiao_shu + xiaoshu, [I] * pow (2 - (I + 1));
}
Sum=zheng_shu + xiao_shu;
//determine the sign bit
If (a [0]==1)
Sum=0 - sum;
return sum;
}
Int main ()
{
Unsigned int a;
Float sum=0;
Int e=0;
Cout<& lt;" Please input is converted into decimal IEEE754 standard short floating-point hexadecimal form: "& lt;
E=get_hex_jiema (get_hex_2b (a));
Cout<& lt;" The size of the order code: "& lt;
Cout<& lt;" Converted to a decimal number is: "& lt;
return 0;
}
Terminal error:
Please input is converted into decimal IEEE754 standard short floating-point hexadecimal form:
Be55b000
Binary code:
10111110010101011011000000000000
The size of the order code: - 3
Binary code:
10111110010101011011000000000000
The terminate called after throwing an instance of 'STD: : length_error'
What () : vector
Have been abandoned (core dump)