我正在查看 SNMPBEECodec,可以在此 位置 查看。
特别地,我正在关注函数 encodeLength()
。
我感兴趣的代码片段如下:
int numBytes = 0;
int temp = length;
while (temp > 0)
{
++numBytes;
temp = (int)Math.floor(temp / 256);
}
(来自Drexel SNMP库)。
我想知道为什么要使用Math.floor()
而不是像temp/256
一样进行简单的整数除法。它似乎会得到相同的结果。还是说有技术上的区别?