A tangled floating-point problem

Source: Internet
Author: User

Recently, a floating-point problem has been encountered,

Code:
FLD DWORD ptr ds:[esi+1e4]

and esi+1e4 = 02fce9d4,

Here is his memory:
02fce9d4 C0 2B C0 2B 45 00 00 00 00 00 00 00 00.? E.? E........

And after execution, ST0 = 2748.00000000000

I want to know how ST0 is equal to 2748?

The analysis is as follows:

After all, the problem of floating-point composition, according to the IEEE Standard, the first bit is the sign bit, then the 8bit is the exponent, the remaining 23bit is the bottom digit, considering the small end storage, the value of the number of C0 2B 45 is 452bc000, that is:
0100 0101 0010 1011 1100 0000 0000 0000
The first bit is 0, which indicates a positive number,
The subsequent 8bit, which is 10001010, 8 A, is converted to decimal 138, 138-127 = 11, indicating that the exponent is 11 bits
The remaining 23-bit values are: 010 1011 1100 0000 0000 0000, the first bit is padded with omitted 1, and the value is:
1010 1011 1100 0000 0000 0000, exponent 11-bit description, the position of the decimal point is:
1010 1011 1100. 0000 0000 0000, converted to 16 in abc.000, converted to 10, which is 2748.00000000

A tangled floating-point problem

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.