/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <stdio.h>
#include <stdint.h>
void unpack_values(uint32_t pack, uint16_t *num1, uint16_t *num2, uint16_t *num3){
*num1 = (uint16_t)(pack >> 20)&0x3FF;
*num2 = (uint16_t)(pack >> 10)&0x3FF;
*num3 = (uint16_t)(pack >> 0)&0x3FF;
}
int main()
{
uint16_t n1;
uint16_t n2;
uint16_t n3;
uint32_t pack = 0x00100803;
unpack_values(pack, &n1, &n2, &n3);
printf("pack=%x => n1=%d n2=%d n3=%d\n", pack, n1, n2, n3);
pack = 0x1172c0aa;
unpack_values(pack, &n1, &n2, &n3);
printf("pack=%x => n1=%d n2=%d n3=%d\n", pack, n1, n2, n3);
return 0;
}