How the floating-point type is stored in memory.

Source: Internet
Author: User
echo number_format(19.99 * 100, 20);    // output:1,998.99999999999977262632

Why is this so? How floating-point types are stored. My idea might be that floating-point types are inherently not exactly stored.
Solve this problem and know why intval the value is 1998 .

Reply content:

echo number_format(19.99 * 100, 20);    // output:1,998.99999999999977262632

Why is this so? How floating-point types are stored. My idea might be that floating-point types are inherently not exactly stored.
Solve this problem and know why intval the value is 1998 .

The storage accuracy of floating-point numbers is related to the system, and PHP typically uses the IEEE 754 double-precision format, which defaults to 20-bit effective precision. Floating point numbers

Floating Point Usage Guide

Floating-point type http://php.net/manual/zh/language.types.float.php with Chinese characters

  • 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.