Here you can find the source of difference(double m1, double M1, double m2, double M2)
private static double difference(double m1, double M1, double m2, double M2)
//package com.java2s; //License from project: Open Source License public class Main { private static double difference(double m1, double M1, double m2, double M2) { if (M1 <= m2) return m2 - M1; if (M2 <= m1) return m1 - M2; //return Math.min(M1, M2) - Math.max(m1, m2); return 0; }/*from w ww .j a v a2s . c o m*/ }