Question: Topic: Coding with bitwise operations Language: Java Pack 4 bytes into an int. The 4 bytes should be placed consecutively in the 32-bit int in
Topic: Coding with bitwise operations
Language: Java
Pack 4 bytes into an int. The 4 bytes should be placed consecutively in the 32-bit int in the order that they appear in the parameters
Example: * pack(0x4B, 0x57, 0xA1, 0x22); // => 0x4B57A122 * pack(0xDE, 0xAD, 0xBE, 0xEF); // => 0xDEADBEEF * * @param b3 Most significant byte (will always be a 8-bit number). * @param b2 2nd Most Significant byte (will always be a 8-bit number). * @param b1 3rd Most significant byte (will always be a 8-bit number). * @param b0 Least significant byte (will always be a 8-bit number). * * @return a 32-bit value formatted like so: b2b1s0 */
int pack(int b3, int b2, int b1, int b0)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
