The reason this works is because the assignment of the int
value to the byte truncates the value. This may be why your math isn't working out - you're not truncating.
Essentially what you're doing by dividing is bitshifting. Your code is the same as this:
byte[0] = (int)number >> 16;
byte[1] = (int)number >> 8;
byte[2] = (int)number;
To make your manual math work, do the math, then convert it to binary, and chop off anything above the last 8 digits. That's the number you're assigning to the byte array.
One example:
byte[1] = (int)number / 256;
This is 167123 / 256 = 652. In binary, this is 001010001100. Now, truncate everything above the size of a byte (8 bits), and you have 10001100, which is 140 in decimal. This is what is assigned to this byte array index.