About
Pricing
Community
Teams
Start Free Trial
Log in
Sathish David Kumar N
asked on
12/31/2018
Why BigDecimal.Sclae() not not working for non decimal value
Why BigDecimal.Sclae() not not working for non decimal value
public static void main(String[] args) {
// TODO Auto-generated method stub
formatBD(2,new BigDecimal(10));
formatBD(2,new BigDecimal(10.0567));
formatBD(2,new BigDecimal(10.05));
formatBD(2,new BigDecimal(10.000023));
}
public static void formatBD(int sca,BigDecimal amount)
{
System.out.println(amount.
scale() > 0 ? amount.setScale(2, BigDecimal.ROUND_CEILING) : amount);
}
}
Output :10
10.06
10.06
10.01
Java
Java EE
3
1
Last Comment
Sathish David Kumar N
8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
CEHJ
1/1/2019
THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
CEHJ
5/22/2019
:)
Sathish David Kumar N
7/23/2019
ASKER
Thanks for your support
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes