Horje
round decimals in java string Code Example
java round to 2 decimal
class round{
    public static void main(String args[]){

      double a = 123.13698;
      double roundOff = Math.round(a*100)/100;

      System.out.println(roundOff);
	}
}
round decimals in java string
package com.mkyong.math.rounding;

public class StringFormatExample {

  public static void main(String[] args) {

      double input = 1205.6358;

      System.out.println("salary : " + input);

      // round half-up, no way control
      // 1205.64
      System.out.println("salary : " + String.format("%.2f", input));

      // 1205.64
      System.out.format("salary : %.2f", input);

  }

}




Java

Related
java grösser gleich Code Example java grösser gleich Code Example
matrix program Code Example matrix program Code Example
Printing cube root of a number in java Code Example Printing cube root of a number in java Code Example
build cmake gradle Code Example build cmake gradle Code Example
spigot bukkit self cancelling task timer example repeat times Code Example spigot bukkit self cancelling task timer example repeat times Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8