Doble float Applet

Source: Internet
Author: User

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/

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.