Code example for BigDecimal

Methods: addsetScalesignum

0
  public static BigDecimal performIntRounding(BigDecimal n)
  { 
    try 
    { 
      // no need to go further if the value is already an integer 
      return n.setScale(0);
    } 
    catch(ArithmeticException e)
    { 
      //ignore and continue 
    } 
     
    final BigDecimal round;
    if(n.signum()<0)
    { 
      n = n.subtract(DELTA);
      return n.setScale(0, BigDecimal.ROUND_UP);
    } 
    else 
    { 
      n = n.add(DELTA);
      round = n.setScale(1, BigDecimal.ROUND_DOWN);
      return round.setScale(0, BigDecimal.ROUND_DOWN);
    } 
  } 
 
  public static BigDecimal performTuneRounding(BigDecimal n)
  { 
Connect your IDE to all the code out there  Get Codota for Java