为什么在 BER 编解码器中使用 Math.floor() 代替整数除法
我正在查看SNMPBEECodec,可以在此位置
看到 特别是我正在查看我感兴趣的功能
A片段encodeLength()
int numBytes = 0;
int temp = length;
while (temp > 0)
{
++numBytes;
temp = (int)Math.floor(temp / 256);
}
(来自 Drexel SNMP 库)。
我想知道为什么使用而不是像.似乎简单的整数除法会得到相同的结果。还是存在技术差异?Math.floor()
temp/256