舍入时PHP奇怪的行为(数字变得非常大)

时间:2012-11-01 10:13:26

标签: php rounding

当我运行时:

<?php echo round(8.553577896, 2); ?>

它返回8.550000000000000710542735760100185871124267578125而不是8.55。为什么?有什么方法可以使用round函数使其正常工作吗?

我在Windows NT 6.1 build 7601(Windows 7旗舰版Service Pack 1)中使用PHP 5.4.4

1 个答案:

答案 0 :(得分:-5)

PHP中是否有round()函数?

<?php
    print round(8.553577896, 2);
?>

试试看,我不完全确定。