Computing an appropriate division scale for pow with negative arguments?
privatestatic BigDecimal pow(BigDecimal bd,int n){
return n < 0 ? BigDecimal.ONE.divide(bd.pow(-n), _ARBITRARY_NUMBER_ , BigDecimal.ROUND_HALF_UP) : bd.pow(n);
}
Rather than plugging in an arbitrarily large number for the scale in the division operation, I would like to try to set the value appropriately. I tried simple formula that basically mulitiplied bd * n / 10, which worked nicely for some values, but gave overly large values for others.
Based on the data that I expect to process I think I could set it to 3000, but I would prefer not to take the risk, and it's just plain stupid to make all calls to the function pay the penalty.
Is there a algorithm that could approximate the value of what the final answer will be so I can plug an appropriate value into the scale?

