Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Splits a multi-byte variable, into single bytes stored in a buffer.
- void split_to_bytes(size_t value_To_Split, uint8_t* pBuf, uint8_t length)
- {
- uint64_t mask = 0xFF; // Mask used for getting the byte
- for(int i=0; i<length; i++) // Loop through the larger variable
- {
- pBuf += i;
- *pBuf = value_To_Split & mask; // Apply the mask to the value, and store it in the buffer
- value_To_Split = value_To_Split >> 8; // Rightshift the value one byte to the right, and loop through again.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement