Home  >  Article  >  Backend Development  >  How many decimal places are kept accurately in PHP

How many decimal places are kept accurately in PHP

不言
不言Original
2018-05-04 15:11:442804browse

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)

##ParametersDescriptionOptional. Specify the number of decimal places. If this parameter is set, numbers are formatted using a period (.) as the decimal point. Optional. Specifies the string used as the decimal point.
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
decimalpoint
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.

Return value: 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!

Statement:
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