on 10-12-2006 3:32 PM
Hi,
I have a big decimal field (789.8098908908908). I want to take only 789.809. Could you please tell how can I do that?.
I appreciate your help on this.
Thanks,
Sunita.
Hi Sunita,
You can use this simple code to truncate the big decimal value.
BigDecimal bb = new BigDecimal("12.32255")
DecimalFormat df = new DecimalFormat("#.##");
manager.reportSuccess(df.format(d));
// Gives out put as 12.32
Regards,
Sridhar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
sunita,
Use this as example:
final BigDecimal value1 = new BigDecimal("789.8098908908908");
System.out.println(value1);
final BigDecimal value2 = value1.setScale(3, BigDecimal.ROUND_DOWN);
System.out.println(value2);
Btw, you have asked almost the same question in another thread:
It is better to continue discussion in one thread and ask additional questions there rather then spawn additional threads.
Valery Silaev
SaM Solutions
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.