25 February 2011

Java Floating Point Bug fixed

 Good news folks!

Oracle (who ate  Sun some time ago) solved bug which celebrate almost 10 years anniversary!

Bug cause an endless loop forms when CPU bravely try converting the number 2.22507385072012e-308 into a floating point number.

If you fancy how it works try this:

If you want enjoy how you program enjoying infinite loop then compile this:

public class FreezeMe {
public static void main(String[] args) {
System.out.println("Am i working ?");
double javakiller = Double.parseDouble("2.2250738585072012e-308");
System.out.println("Value: " + javakiller);
}
}

If you want  see compiler going  into an infinite loop,then try this code:

public class  FreezeMe{
public static void main(String[] args) {
double javakiller = 2.2250738585072012e-308;
System.out.println("Value: " + javakiller);
}
}


I tested on



IDE: Netbeans 6.9.1 and   Eclipse 3.6
JAVA: JDK/JRE 6 update 23

Have fun with JHangOver ;)


Sources:
http://java.dzone.com/
http://www.exploringbinary.com/