How to round float to one decimal point without using DecimalFormat class in java?
<p>I was reading my old notes and found a question where a number with two decimal point is converted to a single decimal point. I looked around for answer and couldn't find it. I cannot keep it string as I have to return as a float and compare it. 
Math.round was rounding it bad and ceil and floor was giving me error. 
I came up with this solution. </p>

<pre><code>public class floatRounding{
 public static void main(String[] args){
  //System.out.println(temperature((float)32.34));
 // System.out.println(temperature((float)32.35));
  if (temperature((float)32.34)&lt;temperature((float)32.35)){
     System.out.println("Here"); 
  }
}

public static float temperature(float t){
  float newt;
  //newt=Math.round(t);

  String tem=String.format("%.1f",(t+.009));
  newt=Float.parseFloat(tem);
  System.out.println(newt);
  return newt;
}
}
</code></pre>

<p>Is there a better solution if I am not using decimal format like in this solution
<a href="https://stackoverflow.com/questions/153724/how-to-round-a-number-to-n-decimal-places-in-java">How to round a number to n decimal places in Java</a></p>

<p>Thanks in advance. Please forgive if its a dumb question.</p>