Here you can find the source of compareTo(double v1, double v2)
public static int compareTo(double v1, double v2)
//package com.java2s; //License from project: Apache License import java.math.BigDecimal; public class Main { public static int compareTo(double v1, double v2) { BigDecimal b1 = new BigDecimal(v1); BigDecimal b2 = new BigDecimal(v2); return b1.compareTo(b2); }//ww w.ja va 2 s . com }