Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { public static double getOverDifference(Double startOvers, Double endOvers) { Double startOvers1 = Math.floor(startOvers); Double startOvers2 = startOvers - startOvers1; Double endOvers1 = Math.floor(endOvers); Double endOvers2 = endOvers - endOvers1; Double diff1 = startOvers1 - endOvers1; Double diff2 = startOvers2 - endOvers2; if (diff2 < 0) { diff1 -= 0.4; // for eg 12 becomes 11.6 } diff1 += diff2; return diff1; } }