Code example for BigDecimal

Methods: compareTo

		int scale = Math.max(bigLeft.scale(), bigRight.scale());
		return normalize(bigLeft.divide(bigRight, Math.max(scale, MAX_DIVISION_SCALE), BigDecimal.ROUND_HALF_UP));
	public int compareToImpl(Number left, Number right) {
		return toBigDecimal(left).compareTo(toBigDecimal(right));
	private BigDecimal normalize(BigDecimal number) {
        // we have to take care of the case number==0, because 0 can have every 
        // scale and the test in the while loop would never end 
        if (number.signum()==0) {
            // the smallest scale for 0 is 0 
            return number.setScale(0);
        // rescale until we found the smallest possible scale 
		try { 
			while (true) { 
				number = number.setScale(number.scale()-1);
Stop searching for code, let great code find you!  Add Codota to your java IDE