# The precision and scale with the divide operation on a bigdecimal

• 05-19-2012, 09:16 AM
marcosol
The precision and scale with the divide operation on a bigdecimal
Hi
I don't understand the scale with de BigDecimal.divide(), example below. Only if I give scale zero it returns 0.25.
But I should give the precision of this method. Is the precision the same as the scale? How do I use the scale correctly?

Code:

```public double getFraction(){                 BigDecimal value1 = new BigDecimal("5000");                 BigDecimal value2 = new BigDecimal("20000");                 return value1.divide(value2,0).doubleValue();         }```
Thanks !
• 05-19-2012, 09:39 AM
JosAH
Re: The precision and scale with the divide operation on a bigdecimal
Normally you shouldn't set the scale value; a BigDecimal is a BigInteger multiplied by pow(10, -scale); the divide( ... ) method you're using sets the rounding mode for the division operator, not its scale (read teh API documentation for the BigDecimal class for details).

kind regards,

Jos