So basically here is what I have. The user gives an integer and I'm converting it into 3 bytes.
int number = 167123;
byte[0] = (int)number / 65536;
byte[1] = (int)number / 256;
byte[2] = (int)number;
stream.Position = 0x503;
stream.WriteByte((byte)byte[2]);
stream.WriteByte((byte)byte[1]);
stream.WriteByte((byte)byte[0]);
(Note: I'm cycling through the byte array backwards on purpose at the end.)
When I check the value later it works as intended. Now I'm looking hard at the code and trying the calculation by hand and I'm not getting the right answer. What am I doing wrong? How is this working? And what is Visual C# writing into the third byte when it casts 167123 as a "byte"?