Topic: Expressions

Online Help


Units


Calcpad provides a comprehensive support for physical units of measurement. The current version, supports metric (SI and compatible), US and Imperial units. There are seven basic units that correspond to the seven physical dimensions:

  • mass - kilogram (kg)
  • length - meter (m)
  • time - second (s)
  • electric current - ampere (A)
  • temperature - degree Celsius (°C)
  • amount of substance - mole (mol)
  • luminous intensity - candela (cd)

All other units are derivative. They are obtained by the respective laws of physics. For example, force = mass·acceleration, so Newton is obtained by N = kg·m/s2. Multiples of units are also supported by adding the respective prefixes to units names. For example, kN = 103N, MN = 106N and so on.

You can attach units to numbers by typing the unit name after the value, e.g. 15kg. Then, you can use them in expressions, just like any other values. Unit cancellation and conversion is performed automatically during calculations. For example, the following expression will be evaluated as:

1.23m + 35cm + 12mm = 1.59m(and not: 1.23 + 35 + 12 = 48.23)

The result is usually obtained into the first unit in the expression. If you want to use particular units, write a vertical bar "|" followed by the target units at the end:

1.23m + 35cm + 12mm|cm

The above expression will evaluate to 159.2cm. If you simply want to convert units, just write the source and the target units, separated by a vertical bar, like: mm|cm or 10m/s|km/h.

Unit consistency is also verified automatically. For example, you cannot add m and s(e.g. 6m + 2s), but you can multiply and divide them 6m/2s = 3m/s.

Arguments for trigonometric, hyperbolic, logarithmic and exponential functions, must be unitless by definition. However, you can use units an any custom defined functions, if it makes any sense. You can also attach units to variables. If you specify the target units in a variable definition, they will be stored permanently inside the variable. Then, the selected units will be used further in the calculations with the respective value. In the next example, speed is calculated in m/s, but it is converted and stored as km/h:

Code Output
'Distance -'s_1 = 50m
'Time -'t_1 = 2s
'Speed -'V = s_1/t_1|km/h
'What distance you will travel for't_2 = 5s'?
s _2 = V*t_2|m
Distance - s1 = 50m
Time - t1 = 2s
Speed - V = s1/t1 = 50m/2s = 90km/h
What distance you will travel for t2 = 5s ?
s2 = V·t2 = 90km/h·5s = 125m

 

Calcpad includes a large collection of predefined units as follows:

Dimensionless:

  • Percent: %;
  • Permille: ;
  • Angles: °degradgradrev;

Metric units (SI and compatible):

  • Mass: ghgkgtktMtGtdgcgmgμgngpgDau;
  • Length: mkmdmcmmmμmnmpmAUly;
  • Time: smsμsnspsminhd;
  • Frequency: HzkHzMHzGHzTHzmHzμHznHzpHzrpm;
  • Speed: kmh;
  • Electric current: AkAMAGATAmAμAnApA;
  • Temperature: °CΔ°CK;
  • Amount of substance: mol;
  • Luminous intensity: cd;
  • Area: adaaha;
  • Volume: LmLcLdLhL;
  • Force: dyn NdaNhNkNMNGNTNgfkgftf;
  • Moment: NmkNm;
  • Pressure: PadaPahPakPaMPaGPaTPadPacPamPaμPanPapPa,
         barmbarμbaratmatTorrmmHg;
  • Viscosity: PcPStcSt;
  • Energy work: JkJMJGJTJmJμJnJpJWhkWhMWhGWhTWhcalkcalerg,
            eVkeVMeVGeVTeVPeVEeV;
  • Power: WkWMWGWTWmWμWnWpWhpMks,
        VAkVAMVAGVATVAmVAμVAnVApVA,
        VARkVARMVARGVARTVARmVARμVARnVARpVAR;
  • Electric charge: CkCMCGCTCmCμCnCpCAhmAh;
  • Potential: VkVMVGVTVmVμVnVpV;
  • Capacitance: FkFMFGFTFmFμFnFpF;
  • Resistance: ΩμΩ;
  • Conductance: SkSMSGSTSmSμSnSpSk℧M℧G℧T℧m℧μ℧n℧p℧;
  • Magnetic flux: Wb kWbMWbGWbTWbmWbμWbnWbpWb;
  • Magnetic flux density: TkTMTGTTTmTμTnTpT;
  • Inductance: HkHMHGHTHmHμHnHpH;
  • Luminous flux: lm;
  • Illuminance: lx;
  • Radioactivity: BqkBqMBqGBqTBqmBqμBqnBqpBqCiRd;
  • Absorbed dose: GykGyMGyGGyTGymGyμGynGypGy;
  • Equivalent dose: SvkSvMSvGSvTSvmSvμSvnSvpSv;
  • Catalytic activity: kat;

Non-metric units (Imperial/US):

  • Mass: grdrozlbkipstqrcwtcwt_UKcwt_UStonton_UKton_USslug;
  • Length: thinftydchfurmiftmcablenmilirodpoleperchlea;
  • Speed: mphknot;
  • Temperature: °FΔ°F°R;
  • Area: roodac;
  • Volume (fluid): fl_ozgiptqtgalbbl, (dry) bu;
            fl_oz_UKgi_UKpt_UKqt_UKgal_UKbbl_UK, (dry) bu_UK;
            fl_oz_USgi_USpt_USqt_USgal_USbbl_US, (dry) bu_US;
  • Force: ozflbfkipftonfpdl;
  • Pressure: osiosf psipsfksiksftsitsfinHg;
  • Energy/work: BTUthermtherm_UKtherm_USquad;
  • Power: hphpEhpS.

Angle units are accepted by trigonometric functions and they override all other settings. Inverse trigonometric functions return unitless values by default. If you want them to return the result in the current units, you have to define a variable: ReturnAngleUnits = 1.

Literals that are written immediately after numbers are recognized as units by the parser, e.g. "2m". Standalone literals can be either units or variables, e.g. "N*m". The rules for parsing are as follows: If a literal has not been defined as a variable, it is parsed as a unit. Otherwise, it is parsed as a variable, even if a unit with the same name exists. If you put a dot before the literal, it will be parsed as a unit, even if a variable with the same name exists, e.g. ".N*.m". In this way, you can also distinguish between the "%" unit and the reminder operator that uses the same symbol. The unit must start with a dot ".%".