This article to give you a brief introduction of the PHP floating point precision value of the instance program, I hope there is a need to understand the accuracy of floating point number of friends can enter the reference.
The precision value of
Floating point numbers are the ones with decimals, and they are not just numbers. when I use the payment interface, I have encountered the problem of floating point loss. let's take a look at the solution. let's take a look at the following code: $
The precision value of a floating-point number in PHP is used to control the output of the floating-point number. Can be understood as the control of the output of the number of digits, the difference in precision, see the output may also be
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
The FLOAT type is used to indicate the approximate numeric data type. The SQL standard allows you to specify the precision (but not the exponential range) with bits in parentheses after the keyword FLOAT ). MySQL also supports optional
1. ScopeThe float and double ranges are determined by the number of digits of the index.The float index has eight digits, while the double index has 11 digits. The distribution is as follows:Float:1bit (symbol bit) 8 bits (index bit) 23 bits (tail
Single-precision and double-precision numeric types appear first in the C language (in a more general language), and in the C language, a single precision type is called a floating-point type (float), as the name implies, by floating a decimal point
The IEEE754 standard describes in detail the format of single-precision floating-point numbers Chaviki Wikipedia ieee_754-1985 describes the categories that include how to express (Statute non-regulated 0 infinite NAN) and why it is so expressedThe
In recent several posts, and QQ group discussion inside, I found that many users have encountered the problem is due to improper use of single-precision/double-precision values. So I want to talk about this topic specifically.Single-and
/** Addition operation, to avoid the data added after the decimal point to produce multiple digits and the loss of computational accuracy. * * @param num1 addend 1 | Num2 Addend 2*/function Numadd (NUM1, num2) {varBasenum, BaseNum1,
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.