--

--

--

--

--

--

--

--

NumberParser code (.NET/C#) >

NumberXNumberX is the generic designation for the following four basic classes of NumberParser:

`Number`

. The most simple and efficient one. It is`decimal`

-based.`NumberD`

. Similar to`Number`

, but capable to deal with any numeric type via`dynamic`

.`NumberO`

. It manages different numeric types simultaneously. The code of its specific functionalities is being analysed in the next section.`NumberP`

. It parses strings into numeric types. There is one section analysing its specific code.

`public`

fields in common:`Value`

. Main numeric information of the given variable. Its type can be either`decimal`

or`dynamic`

(i.e., any supported numeric type).`BaseTenExponent`

. Exponent of the base-ten factor which complements`Value`

when required (i.e., being outside the range of the corresponding numeric type). For example,`Value`

6 and`BaseTenExponent`

3 equals 6*10^3 or 6000.`Error`

. An`ErrorTypesNumber`

variable telling the user about any error, which is managed internally without raising exceptions.

- Custom overloaded functionalities.
- Arithmetic operators.
`Number number = new Number(1m) + 2m;`

- Comparison operators.
`if (new NumberO(1m) < 2m) { //This condition is true. }`

- Implicit conversions between each other.
`Number number = new NumberD(1);`

- Implicit conversions of related types.
`NumberP numberP = "1.2";`

- Arithmetic operators.
- Custom arithmetic operations accounting for their basic
`Value`

-`BaseTenExponent`

-`Error`

structure and managing all the errors internally (i.e., never raising exceptions).

Most of this code is included in Operations_Private_Managed.cs. The contents of this file are very similar to the ones of UnitParser's Operations_Private_Managed.cs and, consequently, the explanations in the corresponding UnitParser section are somehow applicable here too.