Skip to content Skip to sidebar Skip to footer

How I Can To Limit Decimal Numbers Of Double Variable?

How I can to limit decimal numbers of double variable. Indeed I want to change the numbers example 2.34567890 to 2.34 by lower decimal numbers? How to do it? Please help me. Thanks

Solution 1:

Try

double d = 2.34567890;
DecimalFormat newFormat = new DecimalFormat("#.##");
double twoDecimal =  Double.valueOf(newFormat.format(d)); // output 2.35

Post a Comment for "How I Can To Limit Decimal Numbers Of Double Variable?"