int x = (number >> (8*n)) & 0xff;
where n is 0 for the first byte, 1 for the second byte, etc.
More Related Contents:
- Arithmetic bit-shift on a signed integer
- Is the size of C “int” 2 bytes or 4 bytes?
- Are the shift operators () arithmetic or logical in C?
- Right shifting negative numbers in C
- What does the C standard say about bitshifting more bits than the width of type?
- Bitwise operators and “endianness”
- Is CHAR_BIT ever > 8?
- bit shifting with unsigned long type produces wrong results
- C program to check little vs. big endian [duplicate]
- Convert Bytes to Int / uint in C
- What does the statement if (counter & (1
- How do you set only certain bits of a byte in C without affecting the rest?
- C left shift on 64 bits fail
- warning: left shift count >= width of type
- Is there any reason not to use fixed width integer types (e.g. uint8_t)?
- Why use the Bitwise-Shift operator for values in a C enum definition?
- Why does combining two shifts of a uint8_t produce a different result?
- Declaring 64-bit variables in C
- what is the return type of printf [closed]
- Sort words and then the sentence including digits and characters in Shell scripting or perl scripting [closed]
- Why shouldn’t I use atoi()? [duplicate]
- Overloading Macro on Number of Arguments
- How to prevent SIGPIPEs (or handle them properly)
- How to convert enum names to string in c
- Compiler warning – suggest parentheses around assignment used as truth value
- Why Output is 0000 and How? [duplicate]
- How can I throw an exception in C?
- Implicit declaration of ‘gets’
- Unix O_CREAT flag without mode specified
- C: Different implementation of clock() in Windows and other OS?