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

1. Member
Join Date
Feb 2012
Posts
17
Rep Power
0

## 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?

Java Code:
```public double getFraction(){
BigDecimal value1 = new BigDecimal("5000");
BigDecimal value2 = new BigDecimal("20000");
return value1.divide(value2,0).doubleValue();
}```
Thanks !

2. ## 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

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•