What does php floating point mean?

藏色散人
Release: 2023-03-14 21:02:02
Original
7105 people have browsed it

php floating point refers to the Float floating point type, also called floating point number float, double precision number double or real number real. Its definition syntax is such as "$a = 1.234;$b = 1.2e3;"; float The word length of points is platform-dependent, although typically the maximum value is 1.8e308 with a precision of 14 decimal digits.

What does php floating point mean?

The operating environment of this article: Windows7 system, PHP7.1 version, DELL G3 computer

What does php floating point mean?

Float floating point type

Floating point type (also called floating point number float, double precision number double or real number real) can be defined with any of the following syntax ; Precision in decimal digits (64-bit IEEE format).

The precision of floating point numbers

The precision of floating point numbers is limited. Although it depends on the system, PHP usually uses the IEEE 754 double format, so the maximum relative error due to rounding is 1.11e-16. Non-basic mathematical operations may give larger errors, and error propagation when doing compound operations needs to be taken into account.

In addition, rational numbers that can be accurately represented in decimal, such as 0.1 or 0.7, no matter how many mantissas there are, cannot be accurately represented by the binary used internally, and therefore cannot be converted to binary without losing a little precision. Format. This can lead to confusing results: for example, floor((0.1 0.7)*10) will usually return 7 instead of the expected 8, because the internal representation of the result is something like 7.9999999999999991118... .

So never believe that the floating point number result is accurate to the last digit, and never compare whether two floating point numbers are equal. If you really need higher precision, you should use arbitrary precision math functions or the gmp function.

Recommended learning: "

PHP Video Tutorial

"

The above is the detailed content of What does php floating point mean?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!