fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. static long encodeXY(int x, int y) {
  11. return ((1L * x) << 32) | ((1L * y) & 0xFFFFFFFF);
  12. }
  13.  
  14. static int decodeY(long value) {
  15. return (int)(value & 0xFFFFFFFF);
  16. }
  17.  
  18. static int decodeX(long value) {
  19. return (int)(value >> 32);
  20. }
  21.  
  22. public static void main (String[] args) throws java.lang.Exception
  23. {
  24. // your code goes here
  25. long chk = encodeXY(123, 456);
  26. System.out.println(decodeX(chk));
  27. System.out.println(decodeY(chk));
  28. }
  29. }
Success #stdin #stdout 0.1s 320576KB
stdin
Standard input is empty
stdout
123
456