Php determines whether two floating point numbers are equal. php point number _ PHP Tutorial

Source: Internet
Author: User
Php points are used to determine whether two floating point numbers are equal. Php determines whether two floating point numbers are equal. This article describes how php judges whether two floating point numbers are equal. Share it with you for your reference. The specific analysis is as follows: php determines whether two floating point numbers are equal, and php points

This example describes how to use php to determine whether two floating point numbers are equal. Share it with you for your reference. The specific analysis is as follows:

Since it is not completely correct to directly use = to judge whether a floating point number is equal, a method is provided below, which first sets an accuracy. if it is equal within the range of precision, it is considered equal, otherwise, you cannot

<? Php $ delta = 0.00001; $ a = 1.00000001; $ B = 1.00000000; if (abs ($ a-$ B) <$ delta) {/* $ a and $ B are equal */}?>

I hope this article will help you with php programming.

Examples in this article describes how php judges whether two floating point numbers are equal. Share it with you for your reference. The specific analysis is as follows :...

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.