public static float roundFloat(float value,int afterDecimalPoint){
  float mask=(float)Math.pow(10,(float)afterDecimalPoint);
  return (float)(Math.round(value * mask)) / mask;
}

public static float roundFloat ( float value , int afterDecimalPoint ) { float mask = ( float ) Math . pow ( 10 , ( float ) afterDecimalPoint ) ; return ( float ) ( Math . round ( value * mask ) ) / mask ; }
rounds a double to the given number of decimal places .
