我有以下计算:
$this->count = float(44.28)
$multiple = float(0.36)
$calc = $this->count / $multiple;
$calc = 44.28 / 0.36 = 123
现在我想检查我的变量
$calc
是否为整数(有小数点)。
我尝试使用if(is_int()) {}
,但这并不起作用,因为$calc = (float)123
。
还尝试了这个-
if($calc == round($calc))
{
die('is integer');
}
else
{
die('is float);
}
但这也不起作用,因为它在每种情况下都返回'is float'
。在上面的情况下,这是不正确的,因为123经过四舍五入后仍然等于123。
is_int()
函数代替您的代码。 - krishnais_float
? - putvande