Home >Backend Development >PHP Tutorial >How many decimal places are kept accurately in PHP
This article mainly introduces how many decimal places to accurately retain in PHP, which has certain reference value. Now I share it with you. Friends in need can refer to it
number_format() Function to format numbers by thousands grouping.
number_format(number,decimals,decimalpoint,separator)
Description | |
---|---|
number | Required. The number to format. If no other parameters are set, the number will be formatted without a decimal point and with a comma (,) as the thousands separator. |
decimals | Optional. Specify the number of decimal places. If this parameter is set, numbers are formatted using a period (.) as the decimal point.|
decimalpoint | Optional. Specifies the string used as the decimal point.|
separator | Optional. Specifies the string used as thousands separator. Only the first character of the parameter is used. For example, "xxx" only outputs "x".
Notes: If this parameter is set, all other parameters are required. |
Returns the formatted number. |
The above is the detailed content of How many decimal places are kept accurately in PHP. For more information, please follow other related articles on the PHP Chinese website!