public static int round(final float x){
  final int bits=Float.floatToRawIntBits(x);
  final int biasedExp=(bits >> 23) & 0xff;
  final int shift=(23 - 1 + Float.MAX_EXPONENT) - biasedExp;
  if ((shift & -32) == 0) {
    int extendedMantissa=0x00800000 | (bits & 0x007fffff);
    if (bits < 0) {
      extendedMantissa=-extendedMantissa;
    }
    return ((extendedMantissa >> shift) + 1) >> 1;
  }
 else {
    return (int)x;
  }
}

public static int round ( final float x ) { final int bits = Float . floatToRawIntBits ( x ) ; final int biasedExp = ( bits > > 23 ) & 0xff ; final int shift = ( 23 - 1 + Float . MAX_EXPONENT ) - biasedExp ; if ( ( shift & - 32 ) == 0 ) { int extendedMantissa = 0x00800000 | ( bits & 0x007fffff ) ; if ( bits < 0 ) { extendedMantissa = - extendedMantissa ; } return ( ( extendedMantissa > > shift ) + 1 ) > > 1 ; } else { return ( int ) x ; } }
get the closest int to x .
