Floating point number ieee754

Source: Internet
Author: User
Tags decimal to binary
: This article mainly introduces the floating point number ieee754. if you are interested in the PHP Tutorial, refer to it. Convert decimal to computer stored procedure

Taking 9.625 single-precision (32-bit) as an example

  1. Convert decimal to binary representation
    9.625 = 1001.101 = 1x2 3 + 0x22 + 0x21 + 1x20 + 1x2-1 + 0x2-2 + 1x2-3

  2. Binary number normalization
    Ieee 754 requires that the binary representation must follow the format ± d. dd... D × β e, (0 ≤ d I <β)
    That is, 1001.101 = 1.001 101*23

  3. Storage to computer
    32-bit precision
    1-23 indicates the ending number: Because the normalized binary number has only one decimal point on the left side, it can be omitted. in this way, 23 digits are used to represent 24 digits. That is, the ending number is 001 1.001 of 101.
    24-30 indicates the index: 3 of 1.001 101*23
    31 indicates the symbol: 1 indicates a negative number, and 0 indicates a positive number.
    In addition, the index bit has eight digits, which can represent values between 0 and. However, the index may be negative (for example, 0.625 = 0.101 (binary) = 1.01*2-1 ). Therefore, ieee 754 requires that the exponential offset code be added: the normalized exponent value + 127. In this way, the index range is-127-128. Then the above index becomes 130

    According to the above rules, the decimal points after binary are stored in the computer as: [0] [1000 0010] [0011 0100 0000 0000 0000]

Precision loss

  1. It can be seen that the ending part of the normalized binary number may be much longer than 23 bits, so the latter part will be lost during computer storage. Typical is 0.58.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

The above introduces the floating point number ieee 754, including some content, hope to be helpful to friends who are interested in the PHP Tutorial.

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.