Skip to content

Instantly share code, notes, and snippets.

@vinyanalista
Last active August 29, 2015 14:17
Show Gist options
  • Save vinyanalista/030a0264c00a11db0c37 to your computer and use it in GitHub Desktop.
Save vinyanalista/030a0264c00a11db0c37 to your computer and use it in GitHub Desktop.
Teste de convergência em Java
public class Teste {
public static void main(String[] args) {
double num = 0.999999;
int i = 0;
while (num != 0) {
num = num * num;
System.out.println("(" + i + ") num = " + num);
i = i + 1;
if (i == 5000) {
num = 0;
System.out.println("Não convergiu para 0!");
}
}
// Mais alguns testes
System.out.println(new Double(0.0).equals(new Integer(0)));
System.out.println(0.0 == 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment