Conversion to C# from http://thermistor.sourceforge.net/