Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

how to format numbers in java

double value = 4.2352989244d;
String.format("%.2f", value) //output "4.24");
String.format("%.3f", value)//output("4.235");
Comment

number format java

i will refer this site just read it and you will understand everything
i hope this help:https://zetcode.com/java/numberformat/
Comment

number format java


double r = 5.1234;
System.out.println(r); // r is 5.1234

int decimalPlaces = 2;
BigDecimal bd = new BigDecimal(r);

// setScale is immutable
bd = bd.setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP);
r = bd.doubleValue();

System.out.println(r); // r is 5.12

Comment

Number Formating in java

Number Formatting
Comment

PREVIOUS NEXT
Code Example
Java :: what is packages in java 
Java :: java letter alphabet index 
Java :: get element in arraylist java 
Java :: palindrome find in java 
Java :: java exception list 
Java :: Java char data type 
Java :: how to draw a rectangle in libgdx 
Java :: java what is at 
Java :: Finding the Sum of an Array in Java 
Java :: insertion sort in java 
Java :: for cicle java 
Java :: how to update java runtime 
Java :: get string from int java 
Java :: constraintlayout vs coordinatorlayout 
Java :: greatest element in array in java 
Java :: how to initialize an empty array in java 
Java :: read wss endpoint java 
Java :: java clear string buffer 
Java :: There is no client authentication. Try adding an appropriate authentication filter 
Java :: java base64 to file 
Java :: set toolbar background color android 
Java :: Date(Long) to integer and back 
Java :: check if user has internet connection in kotlin 
Java :: javafx get the controller of a pane 
Java :: how to get elements of a list in java 
Java :: how to create a function in java 
Java :: How to read and write XML files 
Java :: Java Create a BufferedWriter 
Java :: java print method 
Java :: java anonymous class 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =