Question about the number_format function of php. echo & nbsp; number_format (88899626759579787, & nbsp; 0, & nbsp;, & nbsp;); why is the output 88899626759579792 & nbsp ;? About the number_format function of php.
Echo number_format (88899626759579787, 0 ,'','');
Why is the output 88899626759579792?
Share:
------ Solution --------------------
I am also a newbie. I asked my mother, and she said the format was wrong!
From http://www.w3school.com.cn/php/func_string_number_format.asp
------ Solution --------------------
Because your environment should be 32-bit, to indicate your above 88899626759579787 numbers, you must use the floating point type, and the floating point type accuracy cannot be guaranteed.
You can see through this example.
Echo PHP_INT_MAX; // The maximum integer that the php integer can represent
Var_dump (number_format (88899626759579700, 0 ,'',''));
------ Solution --------------------
Have you tried to change it according to #1?
------ Solution --------------------
The php long type cannot represent such a large positive number.
Php development organization has never released a 64-bit version for win
------ Solution --------------------
If there are conditions, it is best to upgrade to php5.4 +, because when php is in 5.4, add a parameter to json_decode.
Reference
5.4.0 The options parameter was added.
Bitmask of JSON decode options. Currently only JSON_BIGINT_AS_STRING is supported (default is to cast large integers as floats)
$ Json = '000000 ';
Var_dump (json_decode ($ json ));
Var_dump (json_decode ($ json, false, 512, JSON_BIGINT_AS_STRING ));
?>
The above routine will output:
Float (1.2345678901235E + 19)
String (20) "12345678901234567890"
If the update fails, we recommend that you add a special identifier to the full text that exceeds the int integer length. for example
{"A": "12345678901234567890 "}
You can replace the regular expression
{"A": "_ 12345678901234567890 "}
After json_decode is complete, remove the _ identifier.