Setting the Decimal Place of a Big Decimal Value : BigDecimal « Data Type « Java Tutorial






import java.math.BigDecimal;

public class Main {
  public static void main(String[] argv) throws Exception {
    int decimalPlaces = 2;
    BigDecimal bd = new BigDecimal("123456789.0123456890");
     
    bd = bd.setScale(decimalPlaces, BigDecimal.ROUND_DOWN);
    String string = bd.toString();
  }
}








2.46.BigDecimal
2.46.1.Round a double
2.46.2.Create Big Decimal Values via a long
2.46.3.Create a BigDecimal vis string
2.46.4.Multiply one BigDecimal to another BigDecimal
2.46.5.Subtract from one BigDecimal another BigDecimal
2.46.6.Divide one BigDecimal from another BigDecimal
2.46.7.Negate a BigDecimal
2.46.8.Setting the Decimal Place of a Big Decimal Value
2.46.9.Truncates the big decimal value
2.46.10.Do math operation for BigDecimal
2.46.11.Operate with big decimal values
2.46.12.Create Big Decimal Values via a string
2.46.13.Convert Object to BigDecimal