Entering Data
ODCalc supports the following data types
- Numbers
- Booleans (values which are true or false)
- Strings (text)
Each data type can exist in scalar (single data points) or vector (lists of data points) forms.
Numbers
Numbers in ODCalc consist of a value and a unit. Numbers can be normal real numbers or complex numbers with an imaginary component. Internally numbers are stored as double precision floating point values.
Values
Numbers can be entered in normal decimal format or in scientific format with a decimal part and a ten power part:
The leading decimal can omitted if impatient
If not specified numbers are assumed to be in base ten. Binary, octal and hexadecimal numbers can be entered by prefixing the numbers by 0b, 0o and 0x respectively
Numbers entered in any of the bases don't need to be whole numbers, each of the following numbers are equal to one half:
A complex number can be entered by adding i after the number
i can be used on its own to input 1i. j can be used equivalently to i. The floating point values infinity and not-a-number can be entered using Inf and NaN.
Units
ODCalc will try to interpret text after numbers as a unit. The applications knows about a large set of units which can be input using any of their common names or symbols
If the text matches more than one potential unit (the expression is ambiguous) the calculator will notify this next to the result and allow changing between the possibilities. The currently selected unit system for the calculator will be used to sort the matching units so that the most likely match appears as the default value. This type of ambiguity can be avoided by entering the full name of the unit or by selecting a unit system that more closely matches your work, or modifying a system to suit.
When entering currencies the symbol can be entered before the number when using currency symbols or currency names
Sets of units with the same dimension can be entered as a list, particularly mixed radix imperial values:
Units with powers such as square centimetres can entered by putting the power number at the end of the unit if the power is a positive integer
Composite units are those formed from combinations of other units. Simple units composed by multiplying other units together can be entered by writing the names of units or symbols after each other
Spaces between symbols are optional but can sometimes help to unambiguously identify the correct unit. More complicated units must be entered using the unit operators shown in the following table
| Keyword form | Symbol form | Operation |
|---|---|---|
| (power after unit) | ^: | Unit power |
| sq, square, 2 after unit | :² | Square unit |
| cb, cubic, 3 after unit | :³ | Cube unit |
| √: | Square root unit | |
| ∛: | Cube root unit | |
| per | /: | Divide units |
| ⋅, *: | Multiply units |
All the operators have a symbol form, primarily formed by putting a colon after the normal maths operator. Some also have text forms which can be quicker to enter. The units in the table are listed in order of precedence. For example acceleration can be measured in meters per square second which may be entered using either of these forms:
The unit operators can be useful for adding or removing units from numbers created using other operators (as can the in operator)
Scale factors can be used to conveniently enter large or small values, for example 1000s of metres as kilometres
Three forms of scale factors exist – metric multipliers (factors of 1000 commonly used with metric units), binary multipliers (factors of 1024 commonly used with bytes) and finance multipliers (factors of 1000 commonly used with currencies). Most scale factors have a short (symbol) form and a long form as listed in the table below. Currency multiplier can only be used in conjunction with currency units. Depending on settings within the calculator metric multipliers can be used with all units or only with metric units, likewise binary multipliers can be used with all units or only with bits and bytes.
| Metric | Currency | Binary | ||||||
|---|---|---|---|---|---|---|---|---|
| Short form | Long form | Factor | Short form | Long form | Factor | Short form | Long form | Factor |
| yocto | 10-24 | |||||||
| zepto | 10-21 | |||||||
| atto | 10-18 | |||||||
| f | femto | 10-15 | ||||||
| p | pico | 10-12 | ||||||
| n | nano | 10-9 | ||||||
| µ, u | micro | 10-6 | ||||||
| m | milli | 0.001 | ||||||
| c | centi | 0.01 | ||||||
| d | deci | 0.1 | ||||||
| deca | 10 | |||||||
| hecto | 100 | |||||||
| k | kilo | 1000 | k | thousand | 1000 | Ki, ki | kibi | 1024 |
| M | mega | 106 | M, m, mn | million | 106 | Mi | mebi | 10242 |
| G | giga | 109 | B, b, bn | billion | 109 | Gi | gibi | 10243 |
| T | tera | 1012 | T, t, tr | trillion | 1012 | Ti | tebi | 10244 |
| P | peta | 1015 | Pi | pebi | 10245 | |||
| exa | 1018 | Ei | exbi | 10246 | ||||
| zetta | 1021 | Zi | zebi | 10247 | ||||
| yotta | 1024 | Yi | yobi | 10248 | ||||
Scale factors must appear after the number and before the unit, for example milliamps is entered as mA
where as amp-meters must be entered as Am
When entering currencies the scale factor must appear after the number, but the currency can appear either at the beginning or the end
Scale factors can also be used in arguments for the unit operators
As is conventional, when a composite unit is a power of a single other unit then the scale factor is raised to that power, for example
however for composites that are mixtures of other units the scale factor is applied directly
Finally note the unit-like parts per operators for entering small numbers: % (percent), ‰ (permille), ppm (parts per million), ppb (parts per billion) etc. – see complete list in parts-per form section.
Booleans
Boolean values are used in logical expressions and can have the states true or false. They are entered using the words true or false
Strings
Text, formed from strings of characters known simply as strings, and can be useful for describing intermediate states in calculations. Strings are entered by surrounding the text with double quotes
Escape sequences, special combinations of characters, can be used to enter some characters which are otherwise hard to include as shown in the table below
| Code | Inserts | Code | Inserts |
|---|---|---|---|
| \b | backspace | \r | carriage return |
| \t | tab | \” | double quote |
| \n | line feed | \' | single quote |
| \f | form feed | \\ | backslash |
| \uXXXX | a unicode character, when XXXX is four hexadecimal digits. For example to enter the Russian 'ya' character Я enter \u042F. | ||
Vectors
Vectors (also known as arrays) are lists of values and are entered using square brackets
Operations can then be applied to all the elements of the array in one go
Vectors can have units too, the unit should be expressed following the rules of the numbers section and can be entered either following the array as though it were a number
or applied to each element of the array, the only restriction is that all the elements must have the same dimensions
Vectors in ODCalc can have a single dimension like those shown so far, or can have more dimensions to form a matrix or column vector. To separate the values entered into rows use semicolons, for example multiplying a column vector by the identity matrix
It can sometimes be easier to construct matrices using operators and built in functions, for example a similar calculation to the one above can also be performed using the range operator and identity function
Vectors can also be formed of other data types, for example booleans
and strings