public static Memory bcdiv(Environment env, Memory left, Memory right, int scale){
        BigDecimal bd1 = toBigDecimal(left);
        BigDecimal bd2 = toBigDecimal(right);

        if (bd2.compareTo(BigDecimal.ZERO) == 0) {
            return Memory.NULL;
        }

        BigDecimal result;

        if (scale > 0)
            result = bd1.divide(bd2, scale + 2, RoundingMode.DOWN);
        else
            result = bd1.divide(bd2, 2, RoundingMode.DOWN);

        result = result.setScale(scale, RoundingMode.DOWN);
        return new StringMemory(result.toPlainString());
    }
bcmath extension
http://www.php.net/manual/ru/book.bc.php
exts/jphp-zend-ext/src/main/java/org/develnext/jphp/zend/ext/standard/BCMathFunctions.java