Code example for BigDecimal

Methods: dividescale

        public Number toNumber(String s) {
            return new BigDecimal(s);
        private BigDecimal divide(BigDecimal left, BigDecimal right) {
            int scale1 = left.scale();
            int scale2 = right.scale();
            int scale = Math.max(scale1, scale2);
            scale = Math.max(minScale, scale);
            return left.divide(right, scale, roundingPolicy);
     * An arithmetic engine that conservatively widens the operation arguments 
     * to extent that they can hold the result of the operation. Widening  
     * conversions occur in following situations: 
     * <ul> 
     * <li>byte and short are always widened to int (alike to Java language).</li> 
     * <li>To preserve magnitude: when operands are of different types, the  
Connect your IDE to all the code out there  Get Codota for Java