[ create a new paste ] login | about

Link: http://codepad.org/kCuH0UVW    [ raw code | output | fork ]

C++, pasted on Mar 15:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
int main()
{
  // encode

  int a = 1, b = 10, c = 12;

  int result = a << 8 | b << 4 | c;

  printf( "%X\n", result);


  // decode

  a = result >> 8;
  b = result >> 4 & 0xF;
  c = result & 0xF;

  printf( "a = %d b = %d c = %d\n", a, b, c);
}


Output:
1
2
1AC
a = 1 b = 10 c = 12


Create a new paste based on this one


Comments: