I am looking at the SNMPBEECodec which can be seen at this location
In particular I am looking at the function encodeLength()
A snippet I am interested in
int numBytes = 0;
int temp = length;
while (temp > 0)
{
++numBytes;
temp = (int)Math.floor(temp / 256);
}
(from the Drexel SNMP library).
I would like to know why Math.floor()
is used instead of just a simple integer division like temp/256
. It seems the simple integer division would give the same result. Or is there a technical difference?
Math.floor(temp / 256)
and justtemp / 256
. As sleske pointed out,temp / 256
already yields an integer, so passing it toMath.floor()
does nothing. – Vidafloor
is indeed superfluous. – Beaverette