Quantcast
Channel: web development helpdesk » double
Viewing all articles
Browse latest Browse all 6

How to round decimal value using BigDecimal

$
0
0
You can use the setScale() method to control the rounding of a decimal value as shown in the following example: double value = 123.456789; BigDecimal bd = new BigDecimal(value).setScale(2, BigDecimal.ROUND_HALF_UP); System.out.println(bd);

Viewing all articles
Browse latest Browse all 6

Trending Articles