If you want that for display purposes, use java.text.DecimalFormat
:
new DecimalFormat("#.##").format(dblVar);
If you need it for calculations, use java.lang.Math
:
Math.floor(value * 100) / 100;
More Related Contents:
- Type mismatch: cannot convert from double to double[]
- How to compare BigInteger with double
- Round a double to 2 decimal places [duplicate]
- How to nicely format floating numbers to string without unnecessary decimal 0’s
- Double vs. BigDecimal?
- Convert String to double in Java
- How to change the decimal separator of DecimalFormat from comma to dot/point?
- Float and double datatype in Java
- Why does Math.round(0.49999999999999994) return 1?
- Java:Why should we use BigDecimal instead of Double in the real world? [duplicate]
- How do you test to see if a double is equal to NaN?
- Convert double to BigDecimal and set BigDecimal Precision
- How do I round a double to two decimal places in Java? [duplicate]
- Rounding a double to turn it into an int (java)
- How to implement infinity in Java?
- Is it valid to compare a double with an int in java?
- Why does adding 0.1 multiple times remain lossless?
- Show padding zeros using DecimalFormat
- Java – format double value as dollar amount
- Double cannot be dereferenced?
- Double division behaving wrongly
- Loss of precision – int -> float or double
- Adding and subtracting doubles are giving strange results [duplicate]
- How can I parse a String to BigDecimal? [duplicate]
- Java: Double Value Comparison
- Unexpected result in long/int division
- Java: Inaccuracy using double [duplicate]
- Modulus with doubles in Java
- Double vs double in java [duplicate]
- Force point (“.”) as decimal separator in java