Ask how php is implemented in four homes and six homes (banner rounding? Thank you ~ Ask how php is implemented in four homes and six homes (banner rounding? Thank you ~
Reply content:
Ask how php is implemented in four homes and six homes (banner rounding? Thank you ~
The rounding method is round (). The document is here:
Http://php.net/manual/zh/function.round.php
For example:
Php-r "echo round (1/8, 2 );"
Output:
0.13
However, if your floating point number is not transmitted from other places (for example, $ _ GET or from the database), but calculated by yourself using two numbers, please remember, do not use the +-*/operator built in PHP. Use bcmath and run the following code to find out the cause:
Php-r "echo 19.45-19.35 ;"
I thought you were wrong. I answered the question, and the banker's rounding method is also round (). The third parameter is used.PHP_ROUND_HALF_EVENAndPHP_ROUND_HALF_ODDYes, for example
Php-r "echo round (1/8, 2, PHP_ROUND_HALF_ODD );"
What do you mean by five homes and six homes?
Round ($ number, PHP_ROUND_HALF_DOWN );
UPDATE
I checked it out. Some bankers really round off this four-house-six-in-one, five-view parity practice.
PHP_ROUND_HALF_ODD or PHP_ROUND_HALF_EVEN may be what you want
The manual contains