strictfp public class TestInvSqrt { static final double TEMPOEXECUCAO = 3600; public static void main(String[] args) { double serie = 0.f; // criterio de comparacao long termos = 0l; // contador de termos gerados float i=1.f; // i-esimo termo double tStart, tActual; // tempo, em milisegundos tStart = (double)System.currentTimeMillis()/1000; tActual = (double)System.currentTimeMillis()/1000; while((tActual - tStart) < TEMPOEXECUCAO){ serie = serie + InvSqrt(i++); termos++; tActual = (double)System.currentTimeMillis()/1000; } System.out.println("InvSqrt(x) :: [ "+termos+" ] Termos :: [ "+serie+" ] Serie\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; } }