public static boolean compare ( String v1 , String v2 , CompareMode mode ) { BigDecimal bd1 ; BigDecimal bd2 ; try { bd1 = new BigDecimal ( v1 ) ; bd2 = new BigDecimal ( v2 ) ; int ret = bd1 . compareTo ( bd2 ) ; switch ( mode ) { case LESS : return ret < 0 ; case NOTLESS : return ret >= 0 ; case GREATER : return ret > 0 ; case NOTGREATER : return ret <= 0 ; case EQUAL : return ret == 0 ; default : return false ; } } catch ( Exception e ) { return false ; } }
Compare the input number by given mode The scale will depends on the scale of input number when the result is indivisible