我需要计算N个IP的位掩码。。我从记忆中知道:
32 = 1 IP
31 = 2 IP
30 = 4 IP
29 = 8 IP
等等。
如果i需要8个Ip,则等于POW(2,3)=8;然而,我从8开始,需要倒过来计算。
用PHP计算这个问题的最佳方法是什么?
提前谢谢。。
$bitsrequired = ceil(log($number_of_ips) / log(2));
我需要计算N个IP的位掩码。。我从记忆中知道:
32 = 1 IP
31 = 2 IP
30 = 4 IP
29 = 8 IP
等等。
如果i需要8个Ip,则等于POW(2,3)=8;然而,我从8开始,需要倒过来计算。
用PHP计算这个问题的最佳方法是什么?
提前谢谢。。
$bitsrequired = ceil(log($number_of_ips) / log(2));