Http://blog.csdn.net/Tunix126/archive/2006/10/17/1338464.aspx
There is a website that can help you understand and verify whether your programs are correct,
# Include <stdio. h>
Typedef unsigned long u32;
Typedef struct x_double_type_t x_double_type;
Struct x_double_type_t
{
U32 low_32;
U32 hi_32;
};
# Define double x_double_type
Void F2d (float F, double * X)
{
U32 A, B;
U32 UF = * (u32 *) & F;
U32 * UX = (u32 *) X;
UX [0] = UX [1] = 0;
UX [1] | = UF & 0x80000000;
A = (UF & 0x7f800000)> 23;
B = UF & 0x7fffff;
A + = 1024-128;
UX [1] | = A <20;
UX [1] | = B> 3;
UX [0] | = B <29;
}
Int main ()
{
Float F = 3.14159265f;
Double X;
F2d (F, & X );
Printf ("% lf/N", X );
While (1 = scanf ("% F", & F ))
{
F2d (F, & X );
Printf ("% LG/N", X );
}
Return 0;
}
There was a misunderstanding in understanding the format when I was a beginner. This misunderstanding actually comes from the network. Today I finally have a good understanding. Http://www.ebookee.net/IEEE-float-dl/