Skip to content

Instantly share code, notes, and snippets.

@cnauroth
Created August 20, 2011 20:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cnauroth/1159612 to your computer and use it in GitHub Desktop.
Save cnauroth/1159612 to your computer and use it in GitHub Desktop.
demonstration of Java floating point parsing infinite loop bug discovered in 1/2011
// This causes certain versions of the JVM to enter an infinite loop.
// For more details, see:
// http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308/
// http://www.exploringbinary.com/fpupdater-fixes-the-java-2-2250738585072012e-308-bug/
public class JavaFloatingPointBug {
public static void main(String[] args) {
System.out.println("Test:");
double d = Double.parseDouble("2.2250738585072012e-308");
System.out.println("Value: " + d);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment