Here's the problem:
Given: 32-bit integer
Output: byte array of integer. (assume a byte data type exists)
For example, given the number 1000 in decimal. In Hex it is 0000 0000 0000 1388. As an output, I want an array of bytes = 00 00 00 00 00 00 13 88.
Here would be the signature:
byte * int_to_byte_array( int n)
Sound easy? One catch, you can't use masks or bit shifting. So, you have to do some clever casting. I can't seem to get the right combination going.
Any help?
Given: 32-bit integer
Output: byte array of integer. (assume a byte data type exists)
For example, given the number 1000 in decimal. In Hex it is 0000 0000 0000 1388. As an output, I want an array of bytes = 00 00 00 00 00 00 13 88.
Here would be the signature:
byte * int_to_byte_array( int n)
Sound easy? One catch, you can't use masks or bit shifting. So, you have to do some clever casting. I can't seem to get the right combination going.
Any help?
