Questions about PHP's Number_format function.
Echo Number_format (88899626759579787, 0, ', ');
Why does the output result be 88899626759579792?
Share to:
------Solution--------------------
I am also a novice, asked the next degree Niang, she said, the format is wrong!
Originated from http://www.w3school.com.cn/php/func_string_number_format.asp
------Solution--------------------
Because your environment should be 32-bit, to show you the above 88899626759579787 number, to use floating-point type, and the precision of floating-point type is no way to guarantee.
You can tell by this example.
Echo Php_int_max; Maximum number of integers that can be represented by the shaping of PHP
Var_dump (Number_format (88899626759579700, 0, ', '));
------Solution--------------------
Have you ever tried to change it by #1 say?
------Solution--------------------
Out of bounds, the long type of PHP cannot represent that large positive number
PHP Development organization has never released a 64-bit version of for win
------Solution--------------------
If there is a condition, it would be better to upgrade to php5.4+, because PHP adds a parameter to Json_decode at 5.4.
Reference
5.4.0 The options parameter was added.
Bitmask of JSON decode options. Currently only json_bigint_as_string are supported (default is to cast large integers as floats)
$json = ' 12345678901234567890 ';
Var_dump (Json_decode ($json));
Var_dump (Json_decode ($json, False, json_bigint_as_string));
?>
The above routines will output:
Float (1.2345678901235E+19)
String (20) "12345678901234567890"
If you cannot upgrade, we recommend that you first add a special identifier to the full numeric text that exceeds the int shape length first, for example
{"A": "12345678901234567890"}
Can be replaced by regular
{"A": "__12345678901234567890"}
When the Json_decode is finished, then the __ logo is removed