Here you can find the source of distance(int first, int second)
public static int distance(int first, int second)
//package com.java2s; //License from project: Open Source License public class Main { public static int distance(int first, int second) { return NumberOfSetBits(first ^ second); }/*ww w .jav a 2 s. c o m*/ public static int NumberOfSetBits(int i) { i = i - ((i >>> 1) & 0x55555555); i = (i & 0x33333333) + ((i >>> 2) & 0x33333333); return (((i + (i >>> 4)) & 0x0F0F0F0F) * 0x01010101) >>> 24; } }