You may think it is very easy to convert a floating point number (float) into a string in PHP, but common methods hide serious bugs. because PHP has a very unreasonable way to process floating-point numbers, and the precision will be lost. after research, it is actually a problem for PHP to display floating point numbers... "> <LINKhref =" http://www.php100.com//statics
You may think it is very easy to convert a floating point number (float) into a string in PHP, but common methods hide serious bugs. because PHP has a very unreasonable way to process floating-point numbers, and the precision will be lost. after research, it is actually a BUG in the display of floating point numbers in PHP. PHP built-in echo, var_dump, json_encode, string concatenation and other functions (commands) have problems when displaying floating point numbers, resulting in loss of precision.
$ A = 1315537636.338467;
Printf ("% f", $ a); echo "\ n ";
Echo $ a. "\ n ";
Echo $ a; echo "\ n ";
?>
Result
1315537636.338467
1315537636.3385
1315537636.3385
That is to say, it is impossible to convert a floating point number to a string or display it in PHP's best way. you must use printf/sprintf to convert a floating point number to a string.