Sathish David Kumar N
asked on
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
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.
}
}
Output :10
10.06
10.06
10.01
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:)
ASKER
Thanks for your support