fork(3) download
  1. using System;
  2.  
  3. public class Test
  4. {
  5.  
  6.  
  7. static long Pack(long a24, long b16, long c24) {
  8. return a24<<40 | (b16&0xffffL)<<24 | (c24&0xffffff);
  9. }
  10. static void Unpack(long packed, out int a24, out int b16, out int c24) {
  11. a24 = (int)(packed >> 40); // Sign extension is done in the long
  12. b16 = ((int)(packed >> 8)) >> 16; // Sign extension is done in the int
  13. c24 = ((int)(packed << 8)) >> 8; // Sign extension is done in the int
  14. }
  15.  
  16.  
  17. public static void Main()
  18. {
  19. long p = Pack(0xFFABCD89, 0x7EDC, 0x123456);
  20. Console.WriteLine("{0:x}", p);
  21. int a, b, c;
  22. Unpack(p, out a, out b, out c);
  23. Console.WriteLine("{0:x} {1:x} {2:x}", a, b, c);
  24. }
  25. }
Success #stdin #stdout 0s 131776KB
stdin
Standard input is empty
stdout
abcd897edc123456
ffabcd89 7edc 123456