Link to home
Start Free TrialLog in
Avatar of matthew016
matthew016Flag for Belgium

asked on

BigDecimal

Hi,

I want to divide a BigDecimal by 100,

total = total.divide(new BigDecimal("100"),  ??  );

Can you please help me what the other params must be to have a usual behaviour ?

Thank you.
Avatar of Mick Barry
Mick Barry
Flag of Australia image

u can just use:

total = total.divide(new BigDecimal("100"));
u can supply other parsms to specify scale/rounding if the default behavior does not meet your need.
> total = total.divide(new BigDecimal("100"));

that will leave the scale thew same (as total)
Avatar of matthew016

ASKER

It seems to me that arguments are necessary.
Otherwise I get a compiling error.

I use jdk 1.4.x

then you'll need the following:

total = total.divide(new BigDecimal("100"), BigDecimal.ROUND_HALF_DOWN);

change the round mode to meet your needs.
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial