Chapter 7. Units

Table of Contents

Currency
Conversion
Unit creation/editing

Units give numbers meaning in the real world. They specify what is measured by the numbers and the scale used. Qalculate! fully incorporates units in calculations and includes all standard SI units as well as many non-standard local units. For a complete list of available units see Appendix C, Unit List or the unit manager.

Currency

Among units, Qalculate! has support for currencies with up-to-date exchange rates. Currencies are normally referenced with the standard three letter code due to name clashes, but a number of currency unit can also be accessed through their regular name and symbol. U.S. dollars can, for example, be referenced both as USD and dollar/dollars, or with the $ symbol.

Wget or gvfs must be installed on the computer for exchange rate updates to be enabled. Current exchange rates are automatically fetched from the European Central Bank on the Internet, the first time Qalculate! is started. By default the exchange rates will thereafter have to be updated manually from FileUpdate Exchange Rates, unless automatic updates are enabled in the preferences dialog.

Conversion

Expressions can be converted to a specific unit directly in the expression entry with the to operator, which converts the left-hand expression to a specified unit (ex. 5 feet + 2 inches to cm converts the result of 5 feet + 2 inches to centimeters and displays it). Unit expressions may only contain units, prefixes, exponents, multiplication and division. By default, no prefix will be added to units typed without prefix, but this behavior can be modified by putting a question mark in front of the unit expression (6 561 ft to m ≈ 2000 m but 6 561 ft to ?m ≈ 2 km). Type to optimal to get optimal unit or to base for base units. Other elements are ignored (except bin, oct and hex).

The unit conversion view can also be used. It is shown when pressing Conversion, Ctrl+C, EditConvert To Unit Expression... or Ctrl+T (the last two options moves to focus to the unit expression entry). Enter a unit expression in the text entry and press Enter (or click Convert), or select a unit from the list. An appropriate unit category will automatically be selected from units in the current result. If Continuous expression is checked subsequent results will automatically be converted, and if Set missing prefixes the optimal prefix will be set for unit expressions without any prefix.

Figure 7.1. Unit Conversion Dialog

Unit Conversion Dialog


The final way to convert to another unit is to use the predefined units in the EditConvert To Unit menu or press Convert Result in the unit manager, which also provides quick conversion of a value between two selected units. EditSet Prefix can be used to select a prefix.

It is also possible to let Qalculate! automagically convert the result to appropriate units with EditConvert To Optimal Unit or EditConvert To Base Units (or the corresponding options in the result context menu). If instead the corresponding choice is selected from Mode+Unit Display, each result will automatically be converted until the choice is deactivated (Mode+Unit DisplayNo Automatic Conversion).

Unit creation/editing

There are three different unit classes in Qalculate! — base, alias and composite units. Base units are units defined as basis for other units. Meters and seconds are typical base units. Alias units is defined in relation to another unit. For example, hour is defined as an alias unit that equals 60 minutes which in turn is defined in relation to seconds. Finally, composite units are defined by a unit expression with multiple units. Composite units often have an alias unit associated with them, as they do not have a reference name on their own. For example, a joule is defined as an alias defined in relation to a composite unit defined as Newton * meter.

Select FileNewUnit, or click New in the unit manager, and the unit edit dialog pops up.

Figure 7.2. Unit Edit Dialog

Unit Edit Dialog


First the unit class needs to be selected. Depending on the unit class, different elements in the dialog will be enabled. For all units, category and descriptive name can be specified to keep them well organized. A unit can also be hidden from unit menus with the corresponding check box, which can be useful for some composite units.

Base and alias units normally have three different name forms defined for use in expressions — abbreviation (ex. m), singular (meter) and plural (meters). Composite units only have an internal name, used to reference the unit in definitions of other units.

For base units, the name is all that is needed. For alias units, on the other hand, a base unit, exponent and relation are necessary. The base unit must not necessarily be of the base unit class and it is recommended that an alias unit is defined in relation to the closest unit (ex. 1ft = 3 hands, 1 hand = 4 in, and 1 in = 0.0254 m). The relation is usually just a number that tells how large quantity of the base unit is needed to get the alias unit (alias unit = base unit * relation). The check box below relation in the dialog specifies if the relation is exact or approximate. The exponent defines the exponential relation to the base unit, so that the alias unit equals the base unit raised to the exponent. For simple unit relations this gives: alias unit = relation * base unit^exponent.

Composite units need a unit expression with multiple units as base, in the base unit field. These expressions may only contain units, prefixes, exponents, multiplication and division (ex. km/h).