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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With