ODCalc
Entering Data

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:

1000.0 + 1.0E3 + 1e3
3000

The leading decimal can omitted if impatient

1 + .5
1.5

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

0b10 + 0o10 + 10 + 0x10
36

Numbers entered in any of the bases don't need to be whole numbers, each of the following numbers are equal to one half:

0b0.1 + 0o0.4 + 0.5 + 0x0.8
2

A complex number can be entered by adding i after the number

(1+1000i) * (1-1e3i)
1000001

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

10 newtons * 10 seconds + 1 pound force * 1 minute
366.8933 Ns

10N * 10s + 1lbf * 1min
366.8933 Ns

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

€60 + EUR 50 + euro 40 + 60€ + 50 EUR + 40 euros
€300.00

Sets of units with the same dimension can be entered as a list, particularly mixed radix imperial values:

1 foot 2 inches 250 thou
1.1875 ft

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

10cm2 + 1in2
16.4516 cm2

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

2 volt metres + 2V m + 2Vm
6 Vm

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 formSymbol formOperation
(power after unit)^:Unit power
sq, square, 2 after unitSquare unit
cb, cubic, 3 after unitCube 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:

5 m per sq s + 5 m/:s^:2
10 m/s2

The unit operators can be useful for adding or removing units from numbers created using other operators (as can the in operator)

(1:4) *: m
[1, 2, 3, 4] m

Scale factors can be used to conveniently enter large or small values, for example 1000s of metres as kilometres

4km
4km

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.

MetricCurrencyBinary
Short formLong formFactor Short formLong formFactor Short formLong formFactor
yocto10-24
zepto10-21
atto10-18
ffemto10-15
ppico10-12
nnano10-9
µ, umicro10-6
mmilli0.001
ccenti0.01
ddeci0.1
deca10
hecto100
kkilo1000 kthousand1000 Ki, kikibi1024
Mmega106 M, m, mnmillion106 Mimebi10242
Ggiga109 B, b, bnbillion109 Gigibi10243
Ttera1012 T, t, trtrillion1012 Titebi10244
Ppeta1015 Pipebi10245
exa1018 Eiexbi10246
zetta1021 Zizebi10247
yotta1024 Yiyobi10248

Scale factors must appear after the number and before the unit, for example milliamps is entered as mA

100mA
100 mA

where as amp-meters must be entered as Am

100Am
100 Am

When entering currencies the scale factor must appear after the number, but the currency can appear either at the beginning or the end

won50tr in $
$46.23921 bn

50 tr won in $
$46.23921 bn

Scale factors can also be used in arguments for the unit operators

1.5g per mL
1.5 kg/l

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

1 sq mm / 1 sq m
1e-6

however for composites that are mixtures of other units the scale factor is applied directly

1 mA per sq m / 1 A per sq m
0.001

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.

100ppm in %
0.01 %

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

true & false
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

"abc"
"abc"

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

CodeInsertsCodeInserts
\bbackspace\rcarriage return
\ttab\”double quote
\nline feed\'single quote
\fform feed\\backslash
\uXXXXa unicode character, when XXXX is four hexadecimal digits. For example to enter the Russian 'ya' character Я enter \u042F.

"\u042F is \"ya\" in Russian"
"Я is "ya" in Russian"

Vectors

Vectors (also known as arrays) are lists of values and are entered using square brackets

[1,2,3,4]
[1, 2, 3, 4]

Operations can then be applied to all the elements of the array in one go

[1,2,3,4]*2
[2, 4, 6, 8]

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

100V / [1,2,3,4] kohms
[100, 50, 33.33333, 25] mA

or applied to each element of the array, the only restriction is that all the elements must have the same dimensions

1m * [1m, 2ft, 3", 4um]
[1, 0.6096, 0.0762, 4e-6] m2

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

[1, 2, 3] * [1, 0, 0; 0, 1, 0; 0, 0, 1]
[1, 2, 3]

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

[1:3, 11:13] * eye(6)
[1, 2, 3, 11, 12, 13]

Vectors can also be formed of other data types, for example booleans

[true, true, false] & [false, true, true]
[false, true, false]

and strings

["fish", "sausage"] +" and chips"
["fish and chips", "sausage and chips"]

See Also

Getting Started Entering Data Units Operators Accessing Open Data Vectors Functions