I noticed that packets are sent in an array of bytes.

For example:

{ 0xF7, 0x13, 0xFE }

How can I convert a number such as 396 to a byte array such as this?

Thanks

Code examples aren't necessary. I'd rather just have the algorithm/technique in the conversion explained to me.