About varocarbas.com

--

About me

--

Contact me

--

Visit customsolvers.com, another side of my work

--

Valid markup

--

Valid CSS

--

© 2015-2017 Alvaro Carballo Garcia

--

URL friendly

--

Optimised for 1920x1080 - Proudly mobile unfriendly

R&D projects RSS feed

All projects in full-screen mode

PDFs:

Project 10

Project 9

Project 8

FlexibleParser code analysis:

UnitParser

NumberParser

Tools:

Chromatic encryption

(v. 1.3)

Pages in customsolvers.com:

Upcoming additions

Failed projects

Active crawling bots:

Ranking type 2

(
)

FlexibleParser raw data:

Unit conversion (UnitParser)

Compound types (UnitParser)

Timezones (DateParser)

Currently active or soon to be updated:

Domain ranking

FlexibleParser (DateParser)

NO NEW PROJECTS:
Project 10 is expected to be the last formal project of varocarbas.com. I will continue using this site as my main self-promotional R&D-focused online resource, but by relying on other more adequate formats like domain ranking.
Note that the last versions of all the successfully completed projects (5 to 10) will always be available.
Completed (24 days)
Completed (57 days)
Completed (26 days)
Completed (47 days)
Completed (19 days)
Completed (14 days)

Introduction >

UnitParser Code (.NET/C#) >

Managed calculations

DateParser Code (.NET/C#) >

FlexibleParser
UnitParser code (.NET/C#) >
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:
  • NormaliseUnitInfo. It simplifies/normalises the complex reality of UnitInfo values (i.e., formed by three independent variables with quite big ranges) in order to facilitate all the subsequent arithmetic operations. The goal of this method is to store as much information as possible from Value and Prefix into BaseTenExponent. Note that Prefix is always cleared, but Value might eventually keep some information.
  • PerformManagedOperationUnits. This is the main method in charge of performing arithmetic operations between UnitInfo variables. All the operator overloads defined in the UnitInfo class call this method to perform the corresponding operations.
    This method is the safest way to carry out any operation because it accounts for all the possible scenarios; for example, non-normalised UnitInfo variables or adding/subtracting two variables with different BaseTenExponent values.
  • PerformManagedOperationValues. Unlikely the previous method, this one doesn't perform any pre-check and that's why it should only be used under very specific conditions.
    A typical situation where it might be preferred over PerformManagedOperationUnits is an operation where only Value needs to be considered, at least for one of the variables (e.g., multiplication between UnitP and double variables). Note that PerformManagedOperationValues is quicker and returns a non-normalised variable (i.e., the ideal output under certain conditions).