Java tutorial
//package com.java2s; import java.math.BigDecimal; public class Main { public static int compareTo(Number value1, Number value2) { BigDecimal b1 = new BigDecimal(Double.toString(value1.doubleValue())); BigDecimal b2 = new BigDecimal(Double.toString(value2.doubleValue())); return b1.compareTo(b2); } }