Here you can find the source of zigzagEncode(int input)
public static int zigzagEncode(int input)
//package com.java2s; public class Main { public static int zigzagEncode(int input) { return (input << 1) ^ (input >> 31); }/*from ww w . ja v a2 s . c om*/ public static long zigzagEncode(long input) { return (input << 1) ^ (input >> 63); } }