FlexibleParser
UnitParser code >
Managed calculations
UnitParser was always expected to deal with all the errors internally, an almost-forced decision on account of its somehow-prone-to-errors essence (i.e., a very flexible input system supporting a wide variety of configurations). Additionally and due to the huge variability of potential values together with the high precision and accuracy expectations, the big-number support was also included since almost the beginning.

Before going ahead with the analysis of this code, it is better to know about UnitInfo. As its name indicates, this private class was originally intended to be used internally when dealing with unit-related calculations. The close linkage between unit calculations (e.g., conversions) and numeric calculations (e.g., accounting for a unit prefix value) explains why that initial configuration quickly evolved into the definitive one also dealing with numeric values (i.e., the UnitP fields Value, BaseTenExponent and UnitPrefix).

I call "managed calculations" to the code dealing with the arithmetic operations between UnitInfo variables, where all the errors are managed internally and the UnitP peculiarities (e.g., BaseTenExponent or UnitPrefix) are taken into account. Most of this code is stored in Operations_Private_Managed.cs, which includes the three following main methods:

Previous