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

How many decimal places are kept accurately in PHP

不言
Release: 2023-03-25 11:56:01
Original
2837 people have browsed it

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)
Copy after login

##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!

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template