PHP ROUND对比Javascript ROUND [英] PHP ROUND vs Javascript ROUND
本文介绍了PHP ROUND对比Javascript ROUND的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我发现了一个很奇怪的问题,问题是PHP和Javascript中的ROUND方法的计算结果不一样!?
I found a very strange issue, the issue is the ROUND method in PHP and Javascript the calculation results are not the same!?
请参见以下示例:
PHP
echo round(175.5); // 176
echo round(-175.5); // -176
JavaScript
Javascript
console.log(Math.round(175.5)); // 176
console.log(Math.round(-175.5)); // -175 <-why not -176!!??
有人知道为什么吗?以及如何使Javascript和PHP具有相同的结果?
anyone know why? and how to make Javascript and PHP the same results?
推荐答案
查看全文