User defined units declaration

Common rules must be followed when performing calculations.

Example:

Addition and subtraction must be performed with the same units:

Such variants are false:

Multiplication and division:

The unit is used in the result only if it is declared above the result or exists in an include file.

Example:

The unit Hz is declared in the second line and used in the third line. It does not appear in the first line of the result calculation of the first expression because it is declared later.

There is a specific rule for using a complex unit as a proper fraction: the fraction is considered a unit if it matches all the possible units.

Example:

This example uses complex units. Initially, units "km" and "h." Then, goes their usage.
In the first variant (the third line), the unit is used in a proper way. In the second variant (the fourth line), the unit is also used in a proper way because the string "1000 m/h" is equal to "km/h." In the last example, a proper fraction having "25" as an integer part, which is equivalent to the total of the integral and fraction parts, is declared. This string cannot be considered a unit of measurement because the "2 km/h" unit is not defined. Thus, the following occurs: the first summand (25) has no units, whereas the second (fraction) does. The units of these summands are incompatible.

There is no strict necessity for the unit name to be scientifically or culturally approved. You can declare and use any handy-to-use names.

Example:

The unit "cub_m" is equivalent to the cubic meter. It is automatically added to the result during the calculation (as it is in the present example).