Last active
August 29, 2015 14:17
-
-
Save vinyanalista/030a0264c00a11db0c37 to your computer and use it in GitHub Desktop.
Teste de convergência em Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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