PHP floating point precision problem summary, php floating point precision. PHP floating point number precision problem summary, php floating point precision 1, PHP floating point precision loss first look at the following code: Copy the code: $ f0.5
Let's take a look at the following code:$ F = 0.57;Echo intval ($ f * 100); // 56The result may be a little unexpected. PHP follows IEEE 754 dual precision:Floating point number, expressed in 64-bit dual precision, with one-bit sign bit (E), 11
Engaged in the financial industry, capital operations frequently, here I met the pit .... Slightly inattentive, the user funds may lose hundreds of thousands of, even more terrible ... Go directly to the example:Javascript0.1 + 0.2 Why isn't it
This article is mainly to share with you PHP to achieve high-precision computing, engaged in the financial industry, capital operations frequently, here I met the pit .... Slightly inattentive, the user funds may lose hundreds of thousands of, even
1. Recently I have made some sqlite3 tasks, defining a blob-type field and saving double-precision floating point numbers here, so something strange happened. The double-precision floating point number is 13.46. The hexadecimal value is 402AEB851EB85
PHP floating point Precision problem summary, php floating point Precision
I. Precision loss of PHP floating point numbers
Let's take a look at the following code:Copy codeThe Code is as follows:$ F = 0.57;Echo intval ($ f * 100); // 56
The result
1. Recently doing some sqlite3 things, defined a blob type of field, want to put double-precision floating point in here, so the strange thing happened. Double precision floating point number 13.46, hex 402A EB85 1eb8 51EC, but sqlite inside data is
This article mainly introduces the PHP floating point Precision problem summary, this article discusses the PHP floating point precision loss problem emphatically, uses the three paragraph different way to explain this question formation reason and
In the operation of floating-point numbers in PHP, a hole was encountered, which did not get the expected result, as follows:
$a = 69.1;$b = $a *100;$c = $b-6910;
What do you think the value of $c is? The value $c output is -9.0949470177293E-13.
This article is mainly to share with you how PHP handles high-precision computing functions, the main and we share the two methods, hope to help everyone.
Method 1:
PHP provides a binary calculator (binary Calculator) for any mathematical
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.