Home >Backend Development >PHP Tutorial >溢出 - 如何得到PHP 浮点型的真实值? 1.5265646464633E+21

溢出 - 如何得到PHP 浮点型的真实值? 1.5265646464633E+21

WBOY
WBOYOriginal
2016-06-06 20:41:231048browse

PHP每次导出为csv,数字结尾就会变成E+一个数字。

<code><br>$s = 1526564646463333565222;
echo $s;
//1.5265646464633E+21
</code>

PHP如何才可以将浮点型的字符串反转换为 原始值?

<code>function getTrueValue($str){
    //@todo
}
$str = '1.5265646464633E+21';
</code>

回复内容:

PHP每次导出为csv,数字结尾就会变成E+一个数字。

<code><br>$s = 1526564646463333565222;
echo $s;
//1.5265646464633E+21
</code>

PHP如何才可以将浮点型的字符串反转换为 原始值?

<code>function getTrueValue($str){
    //@todo
}
$str = '1.5265646464633E+21';
</code>

sprintf或者number_format

<code>$s = 1526564646463333565222;
printf("%.0f", $s);
echo "\r\n";
echo number_format($s,0,'','');
</code>
Statement:
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