Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

double parsing algorithm in C#

Tags:

c#

parsing

double

Does anyone know where to find source code for parsing doubles? I'm looking for the algorithm, not the standard "double.Parse" or "double.TryParse" methods.

like image 268
nathan Avatar asked Dec 02 '22 02:12

nathan


2 Answers

Microsoft's source code is available for online browsing. The double parsing code is in System.Number.ParseNumber. It's definitely non-trivial, though, nearly 200 lines long.

You could also use Reflector to see it, though the real code is easier to understand, and has proper comments. You can also download the source for local browsing, by clicking the 'download' link at the top of that page.

Note that this code is copyright Microsoft, so I don't believe you'd be able to use it for anything other than satisfying your curiosity or debugging your application. See http://referencesource.microsoft.com/license.html

like image 151
David Yaw Avatar answered Dec 20 '22 06:12

David Yaw


As an addition to David yaw´s answer with a link to MS .Net Framework source code, I've here the Mono source code. This can be viewed online:

System.Double source code

This code may also be more "free" than MS code.

like image 43
Lasse Espeholt Avatar answered Dec 20 '22 06:12

Lasse Espeholt