Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个数字需要乘以随机数(1-4%)
用 PHP 术语来说,我在想..
$percent = (double) ".0".mt_rand(1,4);
那会产生 0.01 - .04 吗?以数字形式,而不是字符串?
如果这么好,但是有没有更安全/更有效的方法呢?
为什么不只是$percent = mt_rand(1, 4)/100.0;
$percent = mt_rand(1, 4)/100.0;