List of usage examples for java.math BigDecimal ROUND_HALF_UP
int ROUND_HALF_UP
To view the source code for java.math BigDecimal ROUND_HALF_UP.
Click Source Link
From source file:Main.java
public static void main(String args[]) { BigDecimal bd = new BigDecimal(3.14159); bd = bd.setScale(2, BigDecimal.ROUND_HALF_UP); System.out.println(bd);/*from w w w . ja va 2 s.com*/ }
From source file:Main.java
public static void main(String[] args) { BigDecimal bg1 = new BigDecimal("40"); BigDecimal bg2 = new BigDecimal("3"); BigDecimal bg3 = bg1.divide(bg2, BigDecimal.ROUND_HALF_UP); System.out.println(bg3);//from ww w .j av a 2 s . c om }
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 w w w . ja va 2 s . co 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)); }
From source file:Main.java
public static String quzheng(float d) { return new BigDecimal(d).setScale(0, BigDecimal.ROUND_HALF_UP) + ""; }
From source file:Main.java
public static int getIntHalfUp(float f) { BigDecimal bd = new BigDecimal(f).setScale(BigDecimal.ROUND_HALF_UP); return bd.intValue(); }
From source file:Main.java
public static int getRounding(float f) { BigDecimal a = new BigDecimal(f).setScale(0, BigDecimal.ROUND_HALF_UP); return a.intValue(); }
From source file:Main.java
public static float getFloatByHalfUp(float f) { BigDecimal bd = new BigDecimal(f).setScale(2, BigDecimal.ROUND_HALF_UP); return bd.floatValue(); }
From source file:Main.java
public static float divide(int one, int two) { return BigDecimal.valueOf(one).divide(BigDecimal.valueOf(two), 2, BigDecimal.ROUND_HALF_UP).floatValue(); }
From source file:Main.java
public static Integer processCurreny(String value) { BigDecimal bd = new BigDecimal(value); bd.setScale(2, BigDecimal.ROUND_HALF_UP); bd = bd.multiply(new BigDecimal(100)); return bd.intValue(); }
From source file:Main.java
public static String f2Bi(float d) { BigDecimal bigDecimal = new BigDecimal(d); bigDecimal = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP); return bigDecimal.toString(); }