Java BigDecimal Compare compare(BigDecimal v1, BigDecimal v2)

Here you can find the source of compare(BigDecimal v1, BigDecimal v2)

Description

compare

License

LGPL

Declaration

public static int compare(BigDecimal v1, BigDecimal v2) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.math.BigDecimal;

public class Main {

    public static int compare(BigDecimal v1, BigDecimal v2) {
        int intValue = 0;
        Double d1 = v1.doubleValue();
        Double d2 = v2.doubleValue();
        if (d1 > d2) {
            intValue = 1;/*from  ww w.j  av a 2s . c o m*/
        }
        if (d1 == d2) {
            intValue = 0;
        }
        if (d1 < d2) {
            intValue = -1;
        }
        return intValue;
    }
}

Related

  1. compare(BigDecimal decimal, Integer i)
  2. compare(BigDecimal first, BigDecimal second)
  3. compare(BigDecimal one, BigDecimal other)
  4. compareBigDecimal(BigDecimal bigDecimal, BigDecimal bigDecimal2, boolean desc)
  5. compareBigDecimals(java.math.BigDecimal one, java.math.BigDecimal two)
  6. compareTo(BigDecimal b1, BigDecimal b2)
  7. compareTo(final BigDecimal b0, final BigDecimal b1)