Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java remove trailing zeros from float

import java.text.DecimalFormat;


double example = 5.0; 
DecimalFormat myDF = new DecimalFormat("0.#");

//replace 'example' with the float you want to remove trailing zeros from.
System.out.println(myDF.format(example)); //output is 5

 
PREVIOUS NEXT
Tagged: #java #remove #trailing #zeros #float
ADD COMMENT
Topic
Name
5+8 =