import java.nio.ByteBuffer; public class BitConverter { /** * @param args */ public static void main(String[] args) { for(int i=1; i<=100 ;i++){ System.out.println(i); System.out.println("InvSqrt(9) = " + InvSqrt(i)); System.out.println("1/sqrt(9) = " + 1/Math.sqrt(i)); System.out.println("\n"); } } static float InvSqrt(float x){ float xhalf = 0.5f * x; int i = Float.floatToRawIntBits(x); // converte para inteiro mantendo a representacao ieee 754 i = 0x5f3759df - (i >> 1); // a tal operacao x = Float.intBitsToFloat(i); x = x * (1.5f - xhalf * x * x); return x; } }