0 votes
How to round up a value to 2 digit decimal value?
May 10, 2018 in Java 1,009 views

## 2 answers to this question.

0 votes
`double a=324.23456`
`double value = Math.round(a * 100.0) / 100.0;`

Output will be: 324.23

answered May 10, 2018 by
• 4,630 points
0 votes
```double d = 2.34568;
DecimalFormat f = new DecimalFormat("##.00");
System.out.println(f.format(d));```
answered Aug 30, 2018 by
• 6,910 points

0 votes
2 answers

## How to round a double to 2 decimal places?

double value = 200.3456; System.out.printf("Value: %.2f", value); You can ...READ MORE

0 votes
1 answer

## How to round a number to n decimal places in Java?

Use setRoundingMode, set the RoundingMode explicitly to handle your issue ...READ MORE

0 votes
0 answers

## How to round to at most 2 decimal places, if necessary

I'd like to round at most two ...READ MORE

0 votes
2 answers

## How to create a 2-D array in java?

int[][] multi = new int[5][]; multi[0] = new ...READ MORE

0 votes
2 answers

## How can I convert a String variable to a primitive int in Java

Here are two ways illustrating this: Integer x ...READ MORE

0 votes
5 answers

## How to compare Strings in Java?

String fooString1 = new String("foo"); String fooString2 = ...READ MORE

+1 vote
2 answers

## How to generate random integers within specific range in Java?

You can achieve that concisely in Java: Random ...READ MORE

0 votes
1 answer

## How to divide a string in two parts

String s="yourstring"; boolean flag = true; for(int i=0;i<s.length();i++) { ...READ MORE

0 votes
2 answers

## How to round any number to n decimal places in Java?

new BigDecimal(String.valueOf(double)).setScale(yourScale, BigDecimal.ROUND_HALF_UP); will get you a BigDecimal. To ...READ MORE

0 votes
2 answers

## How to test that an array contains a certain value?

public static final String[] VALUES = new ...READ MORE