Double? Integer? — PHP

后端 未结 2 1165
滥情空心
滥情空心 2021-01-29 11:50

The following code generates two random decimal values, then subtracts them to get $c.

$a = mt_rand(5, 75);
$b = mt_rand(5, 75);
$adjuster = mt_rand         


        
2条回答
  •  感动是毒
    2021-01-29 12:41

    A double subtracting a double results in a double, even if that number is a whole number

    $c = (int) ($b - $a);
    

提交回复
热议问题