来自 microtime 的圆形浮点数
PHP 版本 5.3.6
示例
<?php
$timeStart = microtime(true);
// some code ...
$timeExecution = microtime(true) - $timeStart;
$time = round($timeExecution, 2);
file_put_contents('h:/round.txt', $timeExecution . ' = ' . $time . "\n", FILE_APPEND);
?>
文件 round.txt 包含以下行:
131.3048491477966 = 131.3
8.340715885162354 = 8.34
8.198318004608154 = 8.199999999999999
这怎么可能?
PHP Version 5.3.6
Example
<?php
$timeStart = microtime(true);
// some code ...
$timeExecution = microtime(true) - $timeStart;
$time = round($timeExecution, 2);
file_put_contents('h:/round.txt', $timeExecution . ' = ' . $time . "\n", FILE_APPEND);
?>
File round.txt contains these lines:
131.3048491477966 = 131.3
8.340715885162354 = 8.34
8.198318004608154 = 8.199999999999999
how is that possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
http://php.net/manual/en/language.types.float.php
http://php.net/manual/en/language.types.float.php