Unit calculator
Description
With this app, calculations with units can be performed quickly and easily. Expressions - as exemplified in the following table - can be entered directly into the input field.
Input | Result | Comment |
5.32kg - 640g | 4,68kg | The result is automatically normalised to the unit of the first value. |
640g - 5.32kg | -4,680g | Same calculation as above, but in reverse order. |
0g + 5.32kg - 640g | 4,680g | Inserting a zero value with the unit you want in the result. |
3m + 5s | Error | Metres and seconds cannot be added. |
35,50€ + 24,00$ | 55,29381443€ (as of 10.6.2021) | For units with variable conversion, a conversion table must be registered in the system. In the standard system, the EUROFX currency table of the European Central Bank is registered on a daily basis. |
5Packages + 3Pallets | ATTENTION | Such calculations are possible if conversion tables are also used here (e.g. a separate conversion for xpackages = 1pallet per item). |
650g * 25,50[€/kg] | 16,575€ | Please put units as fractions in square brackets. Equal units are automatically shortened. |
2kg*3m/5s² | 1,2N | Since the unit fraction kg*m/s² corresponds to the unit N (=Newton), the result is automatically output in N |
3.5N + 2.8[kg*m/s²] | 6,3N | Entered the unit N as a composite unit. |
2m + 3 + 5cm + 4 | 9,05m | Values without units are allowed. A normalisation of the unit is done to the first unit. |
2cm + 3 + 5m + 4 | 509cm | Here the values are internally set to the unit cm without a unit. |
23 + 6 - 12 | 17 | Calculations without any unit are allowed. |
4 + 3 * 2 | 10 | Point calculation takes precedence over line calculation. |
(4 + 3) * 2 | 14 | Brackets are allowed. |
25,50€ + 19% | 30,345€ | Percentage calculation is possible. |
The calculation is output to memory.
For longer calculations, the individual values can be entered individually via the calculator's keyboard, whereby the entry of a unit is also optional here. After triggering one of the keys with an arithmetic operation, the value is displayed in the memory and is available for further calculation.
When calculating, the rule "dot before dash" is observed. The maximum accuracy of the calculation is 8 decimal places by default.
Functionality
- Change in the percentage calculation
- Change of the number format
- Calculation operations and special keys
- Input via keyboard
Menu item | Description |
---|---|
Percentage calculation | - |
Number format | - |
Change in the percentage calculation
For ease of use, the calculator includes two possible calculation methods for percentage calculation. In the following the differences are clarified by an example, where the calculation "Add 15% to 20" is to be carried out. Depending on the calculation method, the following sequence must be entered into the calculator to obtain the desired result.
- Technical/scientific: 20 + 15% =
- Accounting: 20 x 15% +
Change of the number format
The format of the numbers only refers to the display of the values in the memory, not to the input field. The following properties can be manipulated via the menu line:
Selection of a thousand separator
Use this menu item to activate or deactivate the current separator for thousandths of a number. The separator and the increment are determined by the set location data. Usually a "." or "," is used as a separator and the step size is normally "3". If the separator is activated by selecting "yes", for example, the number "1234.56" is displayed as "1,234.56". When deactivated with "no", the number remains unchanged.
By default the thousand separator is activated.
Number of decimal places
This menu item sets the number of decimal places with which the numbers in the memory are to be displayed. This varies from "exact", i.e. displaying all decimal places, to "3" and "2" to "none" decimal places.
By default, the numbers are displayed with all decimal places.
Rounding of results
This menu item defines the number of decimal places to which a result is to be rounded. If "none" is selected, the result is not rounded at all, otherwise it is rounded to the corresponding decimal place.
No rounding is performed as standard.
Calculation operations and special keys
In the following, the arithmetic operations that can be carried out with this calculator and first the special keys are presented in more detail.
The calculator has two special keys, "AC" and "CE/C". The "CE/C" key clears the input field and the "AC" key also clears the memory. The memory is not only used to visualise the previous calculations, but also to use old values as output values again. To do this, simply double-click on the desired value with the left mouse button to transfer it to the input field.
The settings of the current number format remain unchanged.
In addition to the four basic arithmetic operations, the calculator provides a number of operators that require only one operand to calculate the result, which is fetched from the input field. The result is only returned to the input field. The following operators are provided:
Operation | Function |
---|---|
1/x | reciprocal value formation: This key forms the reciprocal value to the number in the input field. |
% | Percentage calculation: With this key the number in the input field is interpreted as a percentage value. Depending on the percentage calculation mode set and the operator last entered, the current value either refers as a percentage to the value entered before (or the last result) or is divided by 100. If the value is understood as a percentage related to the last value, the currently set unit is no longer relevant, since the unit is defined by the reference value. |
x² | Squaring |
x³ | Potentiate |
x! | Faculty |
Pi | Output of the number Pi |
Sin | Calculate sine |
Cos | Calculate Cosine |
Input via the keyboard
To simplify the input of numbers and not to have to "assemble" each number with the help of the corresponding keystrokes, a direct input of arithmetic expressions is possible in the display of the calculator. To do this, this field is clicked with the mouse, whereupon any expression can now be entered. If only a number or a number with a unit is entered, then this input is displayed again in the appropriate format (separation of number and unit) and remains on the display until an arithmetic operation is triggered.
Related topics
Technical Documentation
Any functionality needed to create a calculator is already available in the classes CX_NUMERIC and CX_VALUE. If this application appears to be relatively large, it is because the calculator was designed to be as comfortable as possible.
The "pure" arithmetic operations, such as the basic arithmetic operations or, for example, the formation of reciprocal values, are all available via the above-mentioned objects. With objects of the class CX_VALUE, it is also checked whether the arithmetic operation may be carried out at all (e.g. "2 m" + "4 sec" is an illegal calculation).
The main part of the application, however, deals with the graphical display of the calculator and the implementation of special calculation methods (e.g. "point before line calculation", "percentage calculation" or also "faculty calculation"). This application shows very clearly that basic functionality, i.e. the "general case", is contained in the model classes, while special requirements, such as "dot before line calculation" are implemented with InstantView®.
Unit pocket calculator module
Module name
calcula.mod
Classes
Security
In addition to restricting access rights via the class and its data fields, the module can be restricted in its use via some of the received messages.
Message | Parameters | Function | Security |
---|---|---|---|
SHOW_UNIT_CALCULATOR | none | Display unit calculator |
Sent messages
none