Here you can find the source of zigzagDecode(int encoded)
public static int zigzagDecode(int encoded)
//package com.java2s; public class Main { public static int zigzagDecode(int encoded) { // canonical: //return (encoded >>> 1) ^ (-(encoded & 1)); if ((encoded & 1) == 0) { // positive return (encoded >>> 1); }//w w w .j a v a 2s. c o m // negative return (encoded >>> 1) ^ -1; } public static long zigzagDecode(long encoded) { // canonical: //return (encoded >>> 1) ^ (-(encoded & 1)); if ((encoded & 1) == 0) { // positive return (encoded >>> 1); } // negative return (encoded >>> 1) ^ -1L; } }