Created
May 28, 2022 10:56
-
-
Save MarcoCiaramella/cda522a8b6cbd5b0182a084bfa2eab42 to your computer and use it in GitHub Desktop.
swap endianess of unsigned int (32bit) and unsigned long long (64bit)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define swap_endianess32(val) (((val>>24) & 0xffu) | ((val>>8) & 0xff00u) | ((val<<8) & 0xff0000u) | ((val<<24) & 0xff000000u)) | |
#define swap_endianess64(val) (((val>>56) & 0xffull) | ((val>>40) & 0xff00ull) | ((val>>24) & 0xff0000ull) | ((val>>8) & 0xff000000ull) | ((val<<8) & 0xff00000000ull) | ((val<<24) & 0xff0000000000ull) | ((val<<40) & 0xff000000000000ull) | ((val<<56) & 0xff00000000000000ull)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment