I just read an interesing blog post: http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308/. It seems that both the Java compiler and the Java runtime freeze when trying to convert the string “2.2250738585072012e-308″ to a double. Next to that, the bug seems quite old and still hasn’t been fixed. Being a .NET enthousiast, it was only natural for me to try this out on .NET and the C# compiler………

The Result:

I’ve used the following code:

—————————————————————————–

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(“Test:”);
            double d = Double.Parse(“2.2250738585072012e-308″);
            Console.WriteLine(d);
            Console.ReadKey();
        }
    }
}

———————————————————————————————-

Note that this wasn’t typed on my normal machine, so no fancy code plug-ins :) . I am happy to announce that…………………………………………………………………………………

It just works as expected!! While I know that there must be bugs present in .Net that are not present in Java, I just thought this was worth a slight chuckle!

Have a nice weekend!!

 

This entry was posted in Various and tagged , , by Alex van Beek. Bookmark the permalink.
Alex van Beek

About Alex van Beek

I'm always keen to keep up with all the new and fancy technologies and I enjoy teaching those technologies to other people. I'm currently specialized in .Net, Flex, (enterprise) Silverlight and mobile development: Android and Windows Phone

5 thoughts on “C# and .NET don’t freeze when converting 2.2250738585072012e-308

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>