How to use float floating-point data type in PHP
This article will explain in detail how to use float floating-point data types in PHP. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Description: decimal, floating point (also known as floating point float, double precision double or real real)
Decimals in php can be expressed in two forms: ordinary decimals or scientific counting.
Code example:
/ / 1var_dump ($num); / / 1$ num = 9.999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
Note: never believe that floating-point results are accurate to the last digit, and never compare whether two floating-point numbers are equal. If you really want higher precision, you should use any precision mathematical function or gmp function.
This is the end of this article on "how to use float floating-point data types in PHP". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.