【发布时间】:2014-01-10 11:04:31
【问题描述】:
您有两个变量,即$a = 5 和$b = 9
这两个语句在数学上的主要区别是什么?
floor(floor($a / $b) - .5); //output: -1
和
(int)((int)($a / $b) - .5); //output: 0
【问题讨论】:
-
猜测:
floor向下舍入(负无穷大),(int)截断(向 0 舍入)。 -
(int) 是类型转换,而不是函数!
-
this question 的热门回答解释了这一点。与上面zch的评论相同。