List of usage examples for org.apache.commons.math3.util Precision round
public static float round(float x, int scale, int roundingMethod) throws MathArithmeticException, MathIllegalArgumentException
From source file:com.super_bits.modulos.paginas.adminTools.PgAdminContainerObjetoTest.java
public static void main(String[] paramentros) { // Ask for user input System.out.print("Enter 1st value:"); // use scanner to read the console input Scanner scan = new Scanner(System.in); String valor = scan.next();/*from ww w .ja v a 2s .c o m*/ double valorAtualizado = Double.parseDouble(valor) * 8.333; double calculoMultiplo = 10 * (Math.ceil(Math.abs(valorAtualizado / 10))); System.out.println(calculoMultiplo); double teste = (double) Math.round(Double.parseDouble(valor) * 8.3d) * 10 / 10d; System.out.println("TEste:" + teste); System.out.println("Result of the operation is " + valor); System.out.println(Precision.round(0.912385, 0, BigDecimal.ROUND_HALF_UP)); int yourScale = 10; System.out.println(BigDecimal.valueOf(0.42344534534553453453 - 0.42324534524553453453).setScale(yourScale, BigDecimal.ROUND_HALF_UP)); }