Here you can find the source of zigZagEncode(int i)
private static final int zigZagEncode(int i)
//package com.java2s; //License from project: Apache License public class Main { /** Same as {@link #zigZagEncode(long)} but on integers. */ private static final int zigZagEncode(int i) { return (i >> 31) ^ (i << 1); }// ww w . ja v a2s . com /** * <a href="https://developers.google.com/protocol-buffers/docs/encoding#types">Zig-zag</a> * encode the provided long. Assuming the input is a signed long whose * absolute value can be stored on <tt>n</tt> bits, the returned value will * be an unsigned long that can be stored on <tt>n+1</tt> bits. */ private static final long zigZagEncode(long l) { return (l >> 63) ^ (l << 1); } }