Code example for BigInteger

Methods: compareTo

0
            case INT:
                return ((Integer) n1).compareTo( (Integer) n2 );
            case LONG:
                return ((Long) n1).compareTo( (Long) n2 );
            case INTEGER:
                return ((BigInteger) n1).compareTo( (BigInteger) n2 );
            case DECIMAL:
                return ((BigDecimal) n1).compareTo( (BigDecimal) n2 );
            case FLOAT:
                return ((Float) n1).compareTo( (Float) n2 );
            case DOUBLE:
                return ((Double) n1).compareTo( (Double) n2 );
            default: 
                throw new IllegalArgumentException( "Unknown number class " + n1.getClass() );
        } 
    } 
         
    public static int getTotalDigits( Number n ) {
        int type = getType( n );
        String str = n.toString();
        int totalDigitsInValue = str.length();