Rules for entering the expressions in the smart unit converter
The dynamic unit converter is designed to understand the user input as a mathematical expression. There are no specific hard and fast rules for the input. In most cases, it should understand the expressions similar to what Microsoft excel can solve. But since it involves the unit keywords to be treated as variables in the expression, there are some exceptions to these rules.
In addition to these exceptions, the program takes some assumptions from the input data if the unit conversion in question has temperature units involved in it.
Input String Format
-
Every input string must have " TO " in it. This is to differentiate between Converting From unit and Converting to unit expression. For Example
Rules for the using expressions.
-
Unit Keywords are case sensitive.
-
A space between two numerical will combine the number. (
why? -> see rule # 16)
-
An empty space between the two units or between a numerical number and a unit is translated as a multiply sign. For example:
Temperature Conversions
-
If the units in the input string are pure temperature units, then temperature conversions are done using the standard methods. For instance, temperature conversion from °F to K uses the expression T [K] = (T[°F] + 459.67)/1.8
-
If the units in the input string are temperature units mixed with other units, then the temperature units in the string will be treated as delta temperatures. For instance, temperature conversion between °F to K use the expression ?T[in K] = ?T[in °F]/1.8. This can be easily derived as:
-
T1 [K] = (T1[in °F] + 459.67)/1.8
T2 [K] = (T2[in °F] + 459.67)/1.8
Using ?T[K] = T1 [K] - T2[K]
=> ?T[K] = (T1[in °F] + 459.67)/1.8 - (T2[in °F] + 459.67)/1.8
=> ?T[K] = (T1[in °F] - T2[in °F] )/1.8
= ?T[in °F]/1.8.
-
Example: 1 Btu/°F to J / K = (1055.87 J) / ( 1/1.8 K) = 1900.566 J/K .
Supported Math operators
-
Add operator: '+'
-
Subtract operator: '-'
-
Multiply operators:
-
'*'
-
' ', i.e. an empty or a white space; An empty space is treated as a multiply operator when placed between two units or between a unit and a constant. Note: For the purpose of multiplication, consecutive empty spaces will be treated as a single multiply sign. Also, an empty space on either side of an operator will be ignored. i.e. 2 m + 3 mm equals 2*m+3*mm and not as 2*m*+*3*mm!
-
'·', i.e. the half high dot (Unicode character # 00B7, Hint: type 00B7 then ALT+X in MS word). Note a half high dot is not same as a decimal point i.e. '.'
-
Divide operators:
-
Power Operator: ^
-
Other helpful keywords: This includes
Limitations
-
To be updated...