Here you can find the source of difference(int start, int boundary)
public static int difference(int start, int boundary)
//package com.java2s; //License from project: Open Source License public class Main { public static int difference(int start, int boundary) { return ((boundary + 1) - (start & boundary)) & boundary; }/*from w ww . j a v a 2 s. c o m*/ }