fork(4) download
  1. import java.math.BigDecimal;
  2. import java.math.RoundingMode;
  3. class RoundNumber {
  4. public static void main(String[] args) throws Exception {
  5. BigDecimal Price = new BigDecimal("232.3315");
  6. BigDecimal Tick = new BigDecimal("10.0");
  7. BigDecimal Price2 = Price.divide(Tick, 9, RoundingMode.HALF_EVEN).setScale(0, RoundingMode.HALF_UP).multiply(Tick);
  8. System.out.println("Price: " + Price + ", Round: " + Tick + ", Converted: " + Price2);
  9. }
  10. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
Price: 232.3315, Round: 10.0, Converted: 230.0