Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是代码:
$val = 65.5401000000000001; return round($val ,2);
我期望得到 65.54,但得到 65.54000000000001。为什么它会这样工作?以及如何获得期望值?
PHP.ini 文件中的precision设置值太高。最好将其保持在默认值 15 以防止这种情况发生。基本上,您所看到的是浮点数无法准确处理实数的结果。
precision