Module:Val/units

From blackwiki
< Module:Val
Revision as of 21:08, 15 August 2015 by blackwiki>Cpiral (fix uM)
Jump to navigation Jump to search

This where you configure Val units. The list of Val units is published at Template:Val/list, and here is the place that produces that report. So preview Template:Space Template:Val/list Template:Space from the edit box to see your changes before saving them. The file format and syntax are mostly self explanatory.

  • You can enter new units in the "Unsorted units" section if you are not sure where else it might go.
  • If the same unit code is defined twice on this page, the first one overrides the later one.
  • Convert and Val share units. If you have an issue with a unit pagename or a unit symbol, and that unit is not published at Val/list, you may decide to address it at Template talk:Convert. To override entries at Convert, make an entry here.
  • If you're not in a hurry, you may notice when editing Val/units that it consists of two Lua string assignments, and Lua comments. Be careful.

Questions or requests related to Val units are welcomed at Template talk:Val. For feedback specifically about the terminology or procedural steps seen on this page, please use the talk page.

Below are the detailed procedures, examples, descriptions of testing and previewing, explanations about sorting Val expressions, and links to helpful pages. There's also further information about Val/Convert relations.

Introduction

An entry defining a unit for Val is a single line under a section heading.[1] It starts with the unit code, followed by at least two spaces and a link. If you are adding a group of related units, you can enter a blank line around them to group them in the report at Val/list. An entry is ignored if it lacks at least two adjacent space characters.

code    [[ pagename | symbol ]]
unit code
The keyboard typeable name of the symbol that users give Val's |u=, |ul=, |up= or |upl= parameters.
  • Unit codes will be case sensitive.
  • Prefer u for the Greek letter μ, if you're not sure.
  • Composite units have dimensions that multiply, divide, and apply powers to component units. Use . to multiply, / to divide, and a signed digit for powers. For multiplication, * is deprecated. When adding a unit that includes division, consider also adding a version with multiplication by the negated power; for example, m/s2 and m.s-2 (for m/s2 and m⋅s−2).
unit pagename
Title or section of an article. When linked with ul or upl, the title or one of its redirects can expand the abbreviation for the unit.[2]
unit symbol
Verifiable, standard symbol, formatted in accordance with WP:UNITS.
  • Templates will not work for producing the unit symbol for input to this module; only Wikipedia HTML formatting is accepted.
  • Composite units use &sdot; to multiply, / to divide, and <sup>...</sup> for powers. Division is also the unit-inversion form that multiplies a negative numbered power, for example for m/s2 and m⋅s−2 (from m.s-2 and m/s2).
  • If the hover-text just shows the abbreviation, it is not a user-friendly unit-symbol. When not linked, the unit's abbreviation can be spelled out with hover-text at the symbol by way of the title attribute of either <abbr>...</abbr> or <span>...</span>.
  • For more about HTML tags and HTML symbols such as &sdot;, see Wikipedia:HTML.
  • For more information about marking up your unit symbol see WP:HTML#formatting.
  • Examples of unit codes, and hover text are at Template:Val/list.
unit code alias
The same unit/pagename/symbol, but by way of a different unit code.
Unit code aliases are commonly applied for
  • capitalization, to make the unit code case insensitive.
  • per units, for example m/s and m⋅s−1.
  • Greek letters, to allow for both US keyboard and Greek-character-input applications, for example the SI prefix μ
Preview page with this template/module
A feature, similar to a sandbox and testcases, that provides a preview of how the code currently in the edit box (sandbox) will look when applied to any page (testcases).

The preview of main interest is Template:Val/list[3], but previewing other your own page of interest with your newly added unit in a val call and in a sorting table are also part of this procedure. Template:Val/units/testcases contains Val calls for all defined Val units.

How to add a unit

To maintain Val units,

  1. Edit Module:Val/units and make your changes.
  2. Preview Template:Space Template:Val/list Template:Space .
    • Look for any messages. An "Invalid definition" message is available automatically.
    • Prove the intended link from the preview.
    • Hover the mouse over the link, and read the hover-text or URL display somewhere in the browser.
  3. Add any unit-code aliases.
  4. Add any sorting if needed. Details about sorting are covered below.
  5. Preview a test page. It will have template Val calls on it, and it may have a sortable table to test sorting. Template:Val/units/testcases is a test page containing Val calls for all units.
  6. Show changes to prove no accidental edits occurred.
  7. Save the page. Saving the page activates the changes immediately, and they go live. You're done adding your unit.

If you want a unit to add for practice, add one from List of common physics notations, or from SI units#Units and prefixes.

Changing or removing existing unit codes is possible by employing {{Template usage}} to see how Val unit codes may or may not be in use on the wiki. For example, to see about changing or removing unit code J.s, do a

{{tlusage|val|"J.s"|0}}Template:Tlusage.

Put any unit code in quotes if it contains dash, dot, or slash—anything but a letter or number. See Template:Val/units/test for a list of these searches for each Val unit.

Examples

Say you're creating a new page or revamping an old page, and discover the need for a convenient way to make several entries containing c0, and link that symbol to the page Speed of light. The following entry will define your unit code as c0, your unit symbol as ''c''<sub>0</sub>, and the unit's article as Speed of light#Numerical value, notation, and units.

c0  [[Speed of light#Numerical value, notation, and unit symbol|''c''<sub>0</sub>]]

or as explained below at §Advanced unit entry formats, you can also write

c0  ''c''<sub>0</sub>      Speed of light#Numerical value, notation, and units

Then preview with Template:Val/list, and check for an error message next to the new unit, and test the link you gave.

After that the page with the (saved) Val calls is used to test the linked and non-linked versions of the normal and the per units:

For an entire example that uses the other format to make a Val/unit entry.

  1. Put this in a sandbox: {{val|1.23|ul=tins}}Template:Val
  2. Edit Module:Val/units and insert a line like the following (do not save yet):
    tins   tins   Contins unities
  3. Under "Preview page with this module" enter Template:Val/list, and click Show preview. It shows Val/list through the version of Val/units in the edit box. Say there are no errors, the markup and hover-text look good, and the link navigates to the unit's page.
  4. Then in the same way of previewing, put the fullpagename of the sandbox from step 1, and click Show preview.
  5. Save page to save the edit to Module:Val/units.

If you want a unit to add for practice, add one from List of common physics notations, or from SI units#Units and prefixes. There are many examples of composite units that have their own page, so adding a unit code for one of those should link to its page. There are many articles that could use a new Val unit, such as molarity at Resveratrol.

Either of the test pages of these examples could have the sortable test-table shown in the next section.

Testing a new unit

To test a newly added unit not used on any page, you will need to run the preview on a sandbox page you have already created. Here are all the test cases you can preview there before saving your changes here; they are the four |u= parameters:

{{Val|9|u =            }}
{{Val|9|ul =           }}
{{Val|9|u=foo|up =     }}
{{Val|9|u=foo|upl =    }}

and the sortable table:

{| class="wikitable sortable" summary="Sortable table to test Val sorting"
! Val number and unit
|-
| {{val|5|u=      }} 
|-
| {{val|3|u=      }} 
|-
| {{val|1|u=      }} 
|-
| {{val|2|u=      }} 
|-
| {{val|4|u=      }} 
|}

This table falls into place unsorted, so when your unit accepts an SI prefix you can test, say, k, m, and G, with your unit, and compare with e notations 1e3, 1e6, and 1e9 in the number. For example, Val sorts these two as equal: 1e3 m (standard e notation) and 1 km.

What to look for
  • The linked and non-linked markup should look exactly the same.
  • Navigate to the new link. It is safe: you can go back in your browser to here.
  • The two |up= versions should have no space in front of them.
  • For SI prefixes sorting 2e3 (or 2000) should be greater than k (kilo prefix).

Advanced unit-entry format

In the usual format

code    [[pagename|symbol]]

the wikilink represents two fields itself, for a total of three fields per entry. But you cannot use a wikilink for composite units that need more than one pagename.

The other record type for adding a unit entry is also three fields. It has the same three fields, but they are in a different order.

code    symbol        pagename

This format separates each field with whitespace, and also takes tabs between fields two and three.

For a new composite unit you should probably link the whole composition, or link the largest portion which could have its own page.

  • The val user can compose a divisor unit on the fly from existing unit codes, and with individually linked numerator and denominator. For example:
{{val|99|ul=m|upl=d}}Template:Val
  • The val user can compose a multiplier unit on the fly by using the |end= parameter to prepend to the unit, and these can also be individually linked. For example (in geology) there is already Template:Val to use with |end=:
{{val|333|ul=uBP|end=&nbsp;[[megaannum|Ma]]}}Template:Val".

For example Template:Val/list says

m.s-1  [[Metre per second|m&sdot;s<sup>&minus;1</sup>]] linking to an article titled Metre per second, not

m.s-1  [[Metre|m]]&sdot;[[Second|s]]<sup>&minus;1</sup> which has separate links to already existing unit codes.

Fourth field flags

The module must be told directly about sorting factors, spacing, and aliasing for a unit code.

There is an optional field that goes at the end after two or more spaces or one or more tabs. It is a flag mainly used to provide for that unit to be sorted in a table. Flags are mainly for sorting, and they work for either record type. Just add two or more spaces, or one or more tabs, and then the flag field. (Optional flags ALIAS and NOSPACE and ANGLE are for even more advanced users. See §Advanced unit flags below.)

Using SI requires that the unit symbol compare precisely to the unit code, and so never allows HTML or other characters in the symbol. Any difference between the unit symbol and unit code must be an SI prefix, such as k, M, or G.

Sorting

Val's sorting scale factor is for comparison to other Val units that might be sorted with it.

Where Sorting is done on the wiki, it is done in sortable tables. Val entries in a sortable table will need a fourth field sorting flag. It can be a number, an equation, or an SI, but it flags the same function: a wikitable sorting "scale".

To display the sort key use |debug=yes. For example

  • {{val|999|u=uV|debug=yes}}6996998999999999999♠999 µV
  • {{val|99|u=V|debug=yes}}7001990000000000000♠99 V
  • {{val|1|u=kV|debug=yes}}7003100000000000000♠1 kV

Scale

For scaling a unit to sort properly, you need to pick a number for a sorting factor. There are numerous examples at Template:Val/list and at Template:Val/sortkey/unit. A system of units will have its base units, for example 1 bit; then the scale for sorting a kilobyte unit is then 8000 (eight bits per byte, times a kilo, or thousand). Or a year scale is seconds so that all times sort by seconds, which is a base unit. In general the scale shows to be "base unit" of the same type times the "SI prefix", and if it's not that simple, then the unit system's number has associated a number to it, such as Avogadro's number.

For example, the following defines a unit with code billion, symbol billion, link 1,000,000,000, and scale 1e9 (Template:Val). After the following entry is saved to the database

billion            billion          1,000,000,000          1e9

{{val|2|u=billion}} would start sorting after {{val|98.7|e=3}}.

SI flag

Metric prefixes in everyday use
Text Symbol Factor Power
tera T Template:Val 1012
giga G Template:Val 109
mega M Template:Val 106
kilo k Template:Val 103
hecto h 100 102
deca da 10 101
(none) (none) 1 100
deci d 0.1 10−1
centi c 0.01 10−2
milli m 0.001 10−3
micro μ Template:Val 10−6
nano n Template:Val 10−9
pico p Template:Val 10−12

SI is used because it scales Val expressions automatically, and it is a clean indicator that the unit will sort properly. It correctly scales any SI prefix for sorting, but not other unit codes.

For SI the unit symbol will not accept HTML, but will accept μ. HTML is not accepted at this time because in order to validate the entry, the unit code must differ from the unit symbol by exactly one valid SI prefix. If there is no difference, or too much difference, it is an invalid definition for sorting purposes. The exception is for the Greek letter μ: if you used a character input application to "install" the Greek letter μ in your symbol, for your "easy to type" unit code, u, these two are not a character mismatch.

All unit entries that use SI will have the same base unit as the symbol at Val/units, but they will display properly at Val/list.

For example, kilo is a thousand, but you're defining km2 for kilometers squared, and need HTML. You can't use SI with HTML, so use 1000*1000, or 1000000 in the sorting field. Use 1e-6 or 0.000001 or 1/100000 instead.

If the unit you are maintaining has SI prefixes and they are all likely to be sorted in a table, add up to twelve entries, one for each common SI unit. Some of these, like Meter in the example, may have their own article, but usually all go to the base unit's pagename. Here is how meter is defined.

m     [[Metre|m]]         SI
cm    [[Centimetre|m]]    SI
dam   [[Decametre|m]]     SI
dm    [[Decimetre|m]]     SI
hm    [[Hectometre|m]]    SI
km    [[Kilometre|m]]     SI
Mm    [[Megametre|m]]     SI
mm    [[Millimetre|m]]    SI
um    [[Micrometre|µm]]   1/1000000
µm    [[Micrometre|m]]    SI
nm    [[Nanometre|m]]     SI
pm    [[Picometre|m]]     SI

The information that was in the unit symbol is now fully specified in, and exhibited at, the unit code. SI specifies that the unit's symbol has been transformed from a symbol to a string for use in string comparison that will finally result in calculating a sorting factor. It conveniently uses the idea that the unit code is often equal to the symbol, especially with SI units. The field definitions are sacrificed for a simplicity in the user presentation, user calculation, and user entry.

In the other format, the following defines three unit codes for volts, V for sorting. V is the base unit with the SI prefix removed. A unit code defined in this manner will have its sort key scaled by the software according to the SI prefix produced by the difference between the unit code and unit symbol.

kV   V   Kilovolt    SI
µV   V   Microvolt   SI
uV   V   Microvolt   SI

Now {{val|1|u=kV}} will sort after {{val|999|u=V}} without having to resort to using a number, and with the clean representation at Val/list.

The symbol column shows "V" for each, but it is not the symbol—it is the base unit after removing the SI prefix so convert can work out what is intended to be the prefix. The following would give identical results:

kV   kV   Kilovolt    1e3
µV   µV   Microvolt   1e-6
uV   µV   Microvolt   1e-6

As you can see, without "SI", you define both the symbol, and the scale. You define the symbol with HTML or the Greek letter or other symbol, and you define the scale with a number or an equation. When "SI" is used, convert just does the right thing for the symbol and scale.

Alias a Convert unit

If you are here to change the link or markup of a unit, but it is not listed at Val/units, sometimes you can find the unit markup and link that you do want, already existing at Template:Convert#Units. In that case you can change the unit code to whatever you'd prefer, and it will achieve your goal. For example, if {{Val|1|C}} is going to Celsius instead of Coulombs, you can define your own unit code, say "degC".

The following defines degC to refer to the unit known as °C in convert. There is no link because a link is defined at Convert.

degC               °C               ALIAS

File format

If you want to reorganize sections here, note that the two lines local builtin_units and local builtin_units_long_scale require a blank line after them. The section long scale, with all the units like "billions" and "trillions", is under the latter, near the bottom of the page. All the rest of the units are in the former.

The file format is two Lua strings and a return statement with them in it: a string in quotes [=[ ... builtin_units ... ]=], and another string in quotes [=[ ... builtin_units_long_scale ... ]=]. The first string, builtin_units, is short-scale, second string is long scale. The reason there are two strings is because of the difference between British and US terms surrounding "billion", "billionth", etc.

For each string there must be a blank line before the first line of the string and after the last line of the string. In other words the first two and last two characters of each string must be newlines.

There is one record per line, starting in first column, having 2-4 fields. The field separator is two or more spaces. Between first and second fields, use two or more spaces. Between all other fields, use two or more spaces, or one or more tabs. Entries without two spaces in them are ignored.

Advanced unit flags

You can alias Convert or Val units. But these are different things.

  • A "unit code alias" is when the same unit pagename and unit symbol are defined twice. If a different unit code is assigned to the same unit symbol and unit pagename, (say, as a copy of the previous entry) it will work as a Val alias.
  • A "unit alias" is when Val alias a Convert unit code. A unit of measurement is here denoted ALIAS to mean "they are defined there". Val defaults to Convert, but it's good to this explicit for certain Val units: the ones tempting to define here, but that you don't want defined here because, says ALIAS, they are already defined there.
  • If your unit code is not listed at {{Val/list}}, you can check for it at {{Val/unitsfromconvert}}, or at {{Convert#Units}}

For spacing and aliasing:

  • ALIAS specifies that the unit's symbol is the code for a unit defined in {{convert}}}.
  • NOSPACE prevents the default insertion of a non-breaking space before the unit symbol.
  • If you see the ANGLE flag, this identifies those special units that must displayed not only after the main Val number, but also after its uncertainty#Measurements numbers.(ANGLE also implies NOSPACE.)

Interaction with Convert

Val and Convert share unit codes, but their units of measurement are different.

  • Most of the wiki's unit codes are managed by {{Convert}}.
  • Some very few unit codes here, like C and F, mean something different there. Val caters to Coulombs and Farads, while Convert caters to Celsius and Fahrenheit. Convert and Val unit codes are mostly identical, like they are for degC and for degF.
  • Val could need any unit, while not all units are needed in conversions, so Val needs all of Convert's units and some of its own.
  • Sorting functionality is handled for Val by {{convert}}.)
  • At Convert the procedure for defining a unit is much more involved than it is here, because there every unit defined must reference associated units, conversion factors, alternate spellings, and many other attributes. An entry at Convert is defined as a multi-line, multi-attribute Lua table with its attendant syntax, and inside a larger Lua script. Therefore Convert is more conservative about adding units. Val may be more liberal in this respect if only because unit entry is simpler and "wikified". Therefore WP:Be bold. Bold customization may be a worthwhile risk at Val/units, or it may get removed. Although units used in articles have definite stylistic standards, there remains room for depending on Val for markup (but see WP:Accessibility about color, link, and text). You may want to customize some Val unit codes that will automate some Val markup for special articles, the talk page, etc. See WP:HTML#formatting for possibilities.

Notes

Template:Refs

See also



  1. Module pages don't have section editing.
  2. A redirect page is easy to make; there are tools on the editor toolbars.
  3. The special relation between Val/units and Val/list is that the wikitext of Val/list is always generated by Val/units when that page is viewed, so when you preview page with this module, Val/list is generated using the contents of the edit box of Val/units.
-- Definitions for units known to val (short scale; see below for long scale).
-- There must be two or more spaces (not tab characters) after the first column,
-- and two spaces (or one or more tab characters) between columns.
-- Lines which do not have two spaces are ignored.
-- There must be a blank line before the first unit and after the last.
-- Unit code       Symbol                                Link                                   Flags/Scale
local builtin_units = [=[

== Test ==
Foo  [[Hz|<samp>Foo</samp>]]
Baz  [[Hertz|baz<sub>0</sub>]]
Bar  bar<abbr title="super duper">0</abbr>   Foobar

== Unsorted units ==
c0  ''c''<sub>0</sub>  Speed of light#Numerical value, notation, and units
lbf                <span title="pound-force">lb<sub>F</sub></span>  Pound (force)
lbf                lb<sub>F</sub>                        Pound (force)
C/mol              C/mol                                 Faraday constant
C.mol-1            C&sdot;mol<sup>−1</sup>               Faraday constant
C/kg               C/kg                                  Roentgen (unit)
C.kg-1             C&sdot;kg<sup>−1</sup>                Roentgen (unit)
F.m-1              F&sdot;m<sup>−1</sup>                 vacuum permittivity
F/m                F/m                                   vacuum permittivity
e                  ''e''                                 Elementary charge

== Time and frequency ==
byte               byte                                  Byte                                   8
byte/s             byte/s                                Bytes per second                       8
kB/s               kB/s                                  Bytes per second                       8e3
MB/s               MB/s                                  Bytes per second                       8e6
GB/s               GB/s                                  Bytes per second                       8e9
TB/s               TB/s                                  Bytes per second                       8e12
bit/s              bit/s                                 Bit per second                         1
bps                bit/s                                 Bit per second                         1
kbit/s             kbit/s                                Kilobit per second                     1e3
Mbit/s             Mbit/s                                Megabit per second                     1e6
Gbit/s             Gbit/s                                Gigabit per second                     1e9
Tbit/s             Tbit/s                                Terabit per second                     1e12
year               year                                  Year                                   31557600
years              years                                 Year                                   31557600
yr                 yr                                    Year#Symbols y and yr                  31557600
y                  y                                     Year                                   31557600
a                  a                                     Annum                                  31557600
Ga                 Ga                                    Gigaannum                              31557600000000000
Ma                 Ma                                    Megaannum                              31557600000000
ka                 ka                                    Kiloannum                              31557600000
kyr                kyr                                   kyr                                    31557600000
kya                kya                                   kyr                                    31557600000
myr                myr                                   myr                                    31557600000000
mya                mya                                   Mya (unit)                             31557600000000
byr                byr                                   Billion years                          31557600000000000
bya                bya                                   Billion years ago                      31557600000000000
Gyr                Ga                                    Year#SI prefix multipliers             31557600000000000
BP                 BP                                    Before present
uBP                <sup>14</sup>C yr BP                  Radiocarbon dating#Calibration
BC                 BC                                    Before Christ                          -1
AD                 AD                                    Anno Domini                            1
BCE                BCE                                   Before the Common Era                  -1
CE                 CE                                    Common Era                             1

s-1                s<sup>−1</sup>                        Second
s-2                s<sup>−2</sup>                        Second
s2                 s<sup>2</sup>                         Second

s                  s                                     Second                                 SI
as                 s                                     Attosecond                             SI
cs                 s                                     Second                                 SI
das                s                                     Second                                 SI
ds                 s                                     Second                                 SI
Es                 s                                     Second                                 SI
fs                 s                                     Femtosecond                            SI
Gs                 s                                     Second                                 SI
hs                 s                                     Second                                 SI
ks                 s                                     Second                                 SI
ms                 s                                     Millisecond                            SI
µs                 s                                     Microsecond                            SI
mus                s                                     Microsecond                            SI
Ms                 s                                     Second                                 SI
ns                 s                                     Nanosecond                             SI
ps                 s                                     Picosecond                             SI
Ps                 s                                     Second                                 SI
Ts                 s                                     Second                                 SI
Ys                 s                                     Second                                 SI
ys                 s                                     Yoctosecond                            SI
Zs                 s                                     Second                                 SI
zs                 s                                     Zeptosecond                            SI

Hz                 Hz                                    Hertz                                  SI
aHz                Hz                                    Hertz                                  SI
cHz                Hz                                    Hertz                                  SI
daHz               Hz                                    Hertz                                  SI
dHz                Hz                                    Hertz                                  SI
EHz                Hz                                    Hertz                                  SI
fHz                Hz                                    Hertz                                  SI
hHz                Hz                                    Hertz                                  SI
GHz                Hz                                    Gigahertz                              SI
kHz                Hz                                    Kilohertz                              SI
MHz                Hz                                    Megahertz                              SI
mHz                Hz                                    Hertz                                  SI
muHz               Hz                                    Hertz                                  SI
µHz                Hz                                    Hertz                                  SI
nHz                Hz                                    Hertz                                  SI
pHz                Hz                                    Hertz                                  SI
PHz                Hz                                    Hertz                                  SI
THz                Hz                                    Hertz                                  SI
yHz                Hz                                    Hertz                                  SI
YHz                Hz                                    Hertz                                  SI
zHz                Hz                                    Hertz                                  SI
ZHz                Hz                                    Hertz                                  SI

== Length, area, volume ==
fb-1               fb<sup>−1</sup>                       Barn (unit)
mas                mas                                   Milliarcsecond                         pi/648000000
m-1                m<sup>−1</sup>                        Metre
m-2                m<sup>−2</sup>                        Square metre
m-3                m<sup>−3</sup>                        Cubic metre
km2                km<sup>2</sup>                        Square kilometre
km3                km<sup>3</sup>                        Cubic kilometre
m                  m                                     Metre
meter              m                                     Metre
metre              m                                     Metre
am                 am                                    Metre
cm                 cm                                    Centimetre
dam                dam                                   Decametre
dm                 dm                                    Decimetre
Em                 Em                                    Metre
fm                 fm                                    Metre
Gm                 Gm                                    Metre
hm                 hm                                    Hectometre
km                 km                                    Kilometre
Mm                 Mm                                    Megametre
mm                 mm                                    Millimetre
mum                µm                                    Micrometre
µm                 µm                                    Micrometre
nm                 nm                                    Nanometre
Pm                 Pm                                    Metre
pm                 pm                                    Picometre
Tm                 Tm                                    Metre
Ym                 Ym                                    Metre
ym                 ym                                    Metre
Zm                 Zm                                    Metre
zm                 zm                                    Metre
µm2                µm<sup>2</sup>                        Square metre
am2                am<sup>2</sup>                        Square metre
cm2                cm<sup>2</sup>                        Square centimetre
dam2               dam<sup>2</sup>                       Square metre
dm2                dm<sup>2</sup>                        Square metre
Em2                Em<sup>2</sup>                        Square metre
fm2                fm<sup>2</sup>                        Square metre
Gm2                Gm<sup>2</sup>                        Square metre
hm2                hm<sup>2</sup>                        Square metre
mm2                mm<sup>2</sup>                        Square metre
Mm2                Mm<sup>2</sup>                        Square metre
nm2                nm<sup>2</sup>                        Square metre
pm2                pm<sup>2</sup>                        Square metre
Pm2                Pm<sup>2</sup>                        Square metre
Tm2                Tm<sup>2</sup>                        Square metre
ym2                ym<sup>2</sup>                        Square metre
Ym2                Ym<sup>2</sup>                        Square metre
zm2                zm<sup>2</sup>                        Square metre
Zm2                Zm<sup>2</sup>                        Square metre
gal                gal                                   Gallon
Gal                Gal                                   Gal (unit)
muGal              µGal                                  Gal (unit)
µGal               µGal                                  Gal (unit)
mGal               mGal                                  Gal (unit)

== Velocity and acceleration ==
m/s2               m/s<sup>2</sup>                       Metre per second squared
m.s-2              m&sdot;s<sup>−2</sup>                 Metre per second squared
m/s                m/s                                   Metre per second
m.s-1              m&sdot;s<sup>−1</sup>                 Metre per second

== Mass and energy ==
lbm                <span title="pound-mass">lb<sub>m</sub></span>   Pound (mass)
muJ                µJ                                    Joule
J.s                J&sdot;s                              Joule-second
kWh                kWh                                   Kilowatt hour
kW.h               kW&sdot;h                             Kilowatt hour
kW·h               kW&sdot;h                             Kilowatt hour
J/C                J/C                                   Volt
J/kg               J/kg                                  Joule

g                  g                                     Gram                               SI
ag                 g                                     Attogram                           SI
cg                 g                                     Centigram                          SI
dag                g                                     Gram                               SI
dg                 g                                     Decigram                           SI
Eg                 g                                     Exagram                            SI
fg                 g                                     Femtogram                          SI
Gg                 g                                     Gigagram                           SI
hg                 g                                     Hectogram                          SI
kg                 g                                     Kilogram                           SI
mcg                g                                     Microgram                          SI
Mg                 g                                     Megagram                           SI
mg                 g                                     Milligram                          SI
mug                g                                     Microgram                          SI
µg                 g                                     Microgram                          SI
ng                 g                                     Nanogram                           SI
Pg                 g                                     Petagram                           SI
pg                 g                                     Picogram                           SI
Tg                 g                                     Tonne                              SI
yg                 g                                     Yoctogram                          SI
Yg                 g                                     Yottagram                          SI
zg                 g                                     Zeptogram                          SI
Zg                 g                                     Zettagram                          SI

== Pressure and density ==
psi                psi                                   Pounds per square inch
g/cm3              g/cm<sup>3</sup>                      Gram per cubic centimetre
kg/m3              kg/m<sup>3</sup>                      Kilogram per cubic metre
kg/cm3             kg/cm<sup>3</sup>                     Density#Formula and common units
g/L                g/L                                   Gram per litre
g/l                g/L                                   Gram per litre
mcg/dL             µg/dL                                 Gram per litre
mcg/dl             µg/dL                                 Gram per litre
mg/mL              mg/mL                                 Gram per litre
mg/ml              mg/mL                                 Gram per litre
mug/dL             µg/dL                                 Gram per litre
mug/dl             µg/dL                                 Gram per litre
μg/dL              μg/dL                                 Gram per litre
μg/dl              μg/dL                                 Gram per litre
mg/Ll              mg/dL                                 Gram per litre
mg/l  [[Gram per litre|<abbr title="milligrams per liter">mg/L</abbr>]]
mg/L  [[Gram per litre|<abbr title="milligrams per liter">mg/L</abbr>]]
mgl-1  [[Gram per litre|<abbr title="milligrams per liter">mg/L</abbr>]]
mgL-1  [[Gram per litre|<abbr title="milligrams per liter">mg/L</abbr>]]

== Temperature ==
degC               °C                                                                       ALIAS
degF               °F                                                                       ALIAS
degR               °R                                                                       ALIAS

K                  K                                     Kelvin                             SI
YK                 K                                     Yottakelvin                        SI
ZK                 K                                     Zettakelvin                        SI
EK                 K                                     Kelvin                          SI
PK                 K                                     Petakelvin                         SI
TK                 K                                     Terakelvin                         SI
GK                 K                                     Gigakelvin                         SI
MK                 K                                     Megakelvin                         SI
kK                 K                                     Kilokelvin                         SI
hK                 K                                     Hectokelvin                        SI
daK                K                                     Decakelvin                         SI
dK                 K                                     Decikelvin                         SI
cK                 K                                     Centikelvin                        SI
mK                 K                                     Millikelvin                        SI
µK                 K                                     Microkelvin                        SI
uK                 K                                     Microkelvin                        SI
nK                 K                                     Nanokelvin                         SI
pK                 K                                     Picokelvin                         SI
fK                 K                                     Femtokelvin                        SI
aK                 K                                     Attokelvin                         SI
zK                 K                                     Zeptokelvin                        SI
yK                 K                                     Yoctokelvin                        SI

== Electromagnetism ==
Wb                 Wb                                    Weber (unit)
N.A-2     N&sdot;A<sup>−2</sup>   Permeability (electromagnetism)
H.m-1              H·m<sup>−1</sup>                      Permeability (electromagnetism)
V/m                V/m                                   Electric field
V.m-1              V&sdot;m<sup>−1</sup>                 Electric field

C                  C                                     Coulomb                            SI
YC  C  Coulomb  SI
ZC                 C                                     Coulomb                            SI
EC                 C                                     Coulomb                            SI
PC                 C                                     Coulomb                            SI
TC                 C                                     Coulomb                            SI
GC                 C                                     Coulomb                            SI
MC                 C                                     Coulomb                            SI
kC                 C                                     Coulomb                            SI
hC                 C                                     Coulomb                            SI
daC                C                                     Coulomb                            SI
dC                 C                                     Coulomb                            SI
cC                 C                                     Coulomb                            SI
mC                 C                                     Coulomb                            SI
µC                 C                                     Coulomb                            SI
uC                 C                                     Coulomb                            SI
nC                 C                                     Coulomb                            SI
pC                 C                                     Coulomb                            SI
fC                 C                                     Coulomb                            SI
aC                 C                                     Coulomb                            SI
zC                 C                                     Coulomb                            SI
yC                 C                                     Coulomb                            SI

F                  F                                     Farad                              SI
YF                 F                                     Farad                              SI
ZF                 F                                     Farad                              SI
EF                 F                                     Farad                              SI
PF                 F                                     Farad                              SI
TF                 F                                     Farad                              SI
GF                 F                                     Farad                              SI
MF                 F                                     Farad                              SI
kF                 F                                     Farad                              SI
hF                 F                                     Farad                              SI
daF                F                                     Farad                              SI
dF                 F                                     Farad                              SI
cF                 F                                     Farad                              SI
mF                 F                                     Farad                              SI
µF                 F                                     Farad                              SI
uF                 F                                     Farad                              SI
nF                 F                                     Farad                              SI
pF                 F                                     Farad                              SI
fF                 F                                     Farad                              SI
aF                 F                                     Farad                              SI
zF                 F                                     Farad                              SI
yF                 F                                     Farad                              SI

H                  H                                     Henry (unit)                       SI
YH                 H                                     Henry (unit)                       SI
ZH                 H                                     Henry (unit)                       SI
EH                 H                                     Henry (unit)                       SI
PH                 H                                     Henry (unit)                       SI
TH                 H                                     Henry (unit)                       SI
GH                 H                                     Henry (unit)                       SI
MH                 H                                     Henry (unit)                       SI
kH                 H                                     Henry (unit)                       SI
hH                 H                                     Henry (unit)                       SI
daH                H                                     Henry (unit)                       SI
dH                 H                                     Henry (unit)                       SI
cH                 H                                     Henry (unit)                       SI
mH                 H                                     Henry (unit)                       SI
µH                 H                                     Henry (unit)                       SI
uH                 H                                     Henry (unit)                       SI
nH                 H                                     Henry (unit)                       SI
pH                 H                                     Henry (unit)                       SI
fH                 H                                     Henry (unit)                       SI
aH                 H                                     Henry (unit)                       SI
zH                 H                                     Henry (unit)                       SI
yH                 H                                     Henry (unit)                       SI

A                  A                                     Ampere                             SI
YA                 A                                     Ampere                             SI
ZA                 A                                     Ampere                             SI
EA                 A                                     Ampere                             SI
PA                 A                                     Ampere                             SI
TA                 A                                     Ampere                             SI
GA                 A                                     Ampere                             SI
MA                 A                                     Ampere                             SI
kA                 A                                     Ampere                             SI
hA                 A                                     Ampere                             SI
daA                A                                     Ampere                             SI
dA                 A                                     Ampere                             SI
cA                 A                                     Ampere                             SI
mA                 A                                     Ampere                             SI
µA                 A                                     Ampere                             SI
uA                 A                                     Ampere                             SI
nA                 A                                     Ampere                             SI
pA                 A                                     Ampere                             SI
fA                 A                                     Ampere                             SI
aA                 A                                     Ampere                             SI
zA                 A                                     Ampere                             SI
yA                 A                                     Ampere                             SI

V                  V                                     Volt                               SI
YV                 V                                     Volt                               SI
ZV                 V                                     Volt                               SI
EV                 V                                     Volt                               SI
PV                 V                                     Volt                               SI
TV                 V                                     Volt                               SI
GV                 V                                     Volt                               SI
MV                 V                                     Volt                               SI
kV                 V                                     Volt                               SI
hV                 V                                     Volt                               SI
daV                V                                     Volt                               SI
dV                 V                                     Volt                               SI
cV                 V                                     Volt                               SI
mV                 V                                     Volt                               SI
µV                 V                                     Volt                               SI
uV                 V                                     Volt                               SI
nV                 V                                     Volt                               SI
pV                 V                                     Volt                               SI
fV                 V                                     Volt                               SI
aV                 V                                     Volt                               SI
zV                 V                                     Volt                               SI
yV                 V                                     Volt                               SI

R                  R                                     Rayleigh (unit)                    SI

G                  G                                     Gauss (unit)                       SI
aG                 G                                     Attogauss                          SI
cG                 G                                     Centigauss                         SI
daG                G                                     Decagauss                          SI
dG                 G                                     Decigauss                          SI
EG                 G                                     Exagauss                           SI
fG                 G                                     Femtogauss                         SI
GG                 G                                     Gigagauss                          SI
hG                 G                                     Hectogauss                         SI
kG                 G                                     Kilogauss                          SI
MG                 G                                     Megagauss                          SI
mG                 G                                     Milligauss                         SI
muG                G                                     Microgauss                         SI
µG                 G                                     Microgauss                         SI
nG                 G                                     Nanogauss                          SI
PG                 G                                     Petagauss                          SI
pG                 G                                     Picogauss                          SI
TG                 G                                     Teragauss                          SI
yG                 G                                     Yoctogauss                         SI
YG                 G                                     Yottagauss                         SI
zG                 G                                     Zeptogauss                         SI
ZG                 G                                     Zettagauss                         SI

T                  T                                     Tesla (unit)                       SI
aT                 T                                     Attotesla                          SI
cT                 T                                     Centitesla                         SI
daT                T                                     Decatesla                          SI
dT                 T                                     Decitesla                          SI
ET                 T                                     Exatesla                           SI
fT                 T                                     Femtotesla                         SI
GT                 T                                     Gigatesla                          SI
hT                 T                                     Hectotesla                         SI
kT                 T                                     Kilotesla                          SI
MT                 T                                     Megatesla                          SI
mT                 T                                     Millitesla                         SI
muT                T                                     Microtesla                         SI
µT   T   Microtesla  SI
nT                 T                                     Nanotesla                          SI
PT                 T                                     Petatesla                          SI
pT                 T                                     Picotesla                          SI
TT                 T                                     Teratesla                          SI
yT                 T                                     Yoctotesla                         SI
YT                 T                                     Yottatesla                         SI
zT                 T                                     Zeptotesla                         SI
ZT                 T                                     Zettatesla                         SI

== Astrophysics ==
au                 au                                    Astronomical unit
c                  ''c''                                 Speed of light
ly                 ly                                    Light-year
Earth mass         ''M''<sub>⊕</sub>                     Earth mass
Earth radius       ''R''<sub>⊕</sub>                     Earth radius
M_Earth            ''M''<sub>⊕</sub>                     Earth mass
R_Earth            ''R''<sub>⊕</sub>                     Earth radius
Jupiter mass       ''M''<sub>J</sub>                     Jupiter mass
Jupiter radius     ''R''<sub>J</sub>                     Jupiter radius
M_Jupiter          ''M''<sub>J</sub>                     Jupiter mass
R_Jupiter          ''R''<sub>J</sub>                     Jupiter radius
Solar mass         ''M''<sub>&#x2609;</sub>              Solar mass
solar mass         ''M''<sub>&#x2609;</sub>              Solar mass
M_Solar            ''M''<sub>&#x2609;</sub>              Solar mass
M_solar            ''M''<sub>&#x2609;</sub>              Solar mass
R_Solar            ''R''<sub>&#x2609;</sub>              Solar radius
R_solar            ''R''<sub>&#x2609;</sub>              Solar radius
Solar radius       ''R''<sub>&#x2609;</sub>              Solar radius
solar radius       ''R''<sub>&#x2609;</sub>              Solar radius
Solar luminosity   ''L''<sub>&#x2609;</sub>              Solar luminosity
solar luminosity   ''L''<sub>&#x2609;</sub>              Solar luminosity
L_solar            ''L''<sub>&#x2609;</sub>              Solar luminosity
L_Solar            ''L''<sub>&#x2609;</sub>              Solar luminosity
pc2                pc<sup>2</sup>                        Parsec
pc3                pc<sup>3</sup>                        Parsec
kpc2               kpc<sup>2</sup>                       Parsec#Parsecs and kiloparsecs
kpc3               kpc<sup>3</sup>                       Parsec#Parsecs and kiloparsecs
kpc                kpc                                   Parsec#Parsecs and kiloparsecs
Mpc2               Mpc<sup>2</sup>                       Parsec#Megaparsecs and gigaparsecs
Mpc3               Mpc<sup>3</sup>                       Parsec#Megaparsecs and gigaparsecs
Mpc                Mpc                                   Parsec#Megaparsecs and gigaparsecs
Gpc2               Gpc<sup>2</sup>                       Parsec#Megaparsecs and gigaparsecs
Gpc3               Gpc<sup>3</sup>                       Parsec#Megaparsecs and gigaparsecs
Gpc                Gpc                                   Parsec#Megaparsecs and gigaparsecs

== Nuclear Physics and Chemistry ==
cm-1               cm<sup>−1</sup>                       Wavenumber
u                  u                                     Atomic mass unit
osmol              osmol                                 Osmole (unit)
Osm                Osm                                   Osmole (unit)
M  [[Molarity|M]]
TM  [[Molarity|TM]]  SI
GM  [[Molarity|GM]]  SI
MM  [[Molarity|MM]]  SI
kM  [[Molarity|kM]]  SI
hM  [[Molarity|hM]]  SI
daM  [[Molarity|daM]]  SI
dM  [[Molarity|dM]]  SI
cM  [[Molarity|cM]]  SI
mM  [[Molarity|mM]]  SI
uM  [[Molarity|µM]]  1e-6
nM  [[Molarity|nM]]  SI
pM  [[Molarity|pM]]  SI
kg/mol             kg/mol                                Molar mass
kg.mol-1           kg&sdot;mol<sup>−1</sup>              Molar mass
g/mol              g/mol                                 Molar mass
g.mol-1            g&sdot;mol<sup>−1</sup>               Molar mass
eV/c2              eV/''c''<sup>2</sup>                  Electronvolt#Mass
keV/c2             keV/''c''<sup>2</sup>                 Electronvolt#Mass
MeV/c2             MeV/''c''<sup>2</sup>                 Electronvolt#Mass
GeV/c2             GeV/''c''<sup>2</sup>                 Electronvolt#Mass
TeV/c2             TeV/''c''<sup>2</sup>                 Electronvolt#Mass
µN                 µ<span style="display:inline-block;margin-bottom:-0.3em;vertical-align:-0.4em;line-height:1.2em;font-size:85%;text-align:left"><br />N</span>     Nuclear magneton
µB                 µ<span style="display:inline-block;margin-bottom:-0.3em;vertical-align:-0.4em;line-height:1.2em;font-size:85%;text-align:left"><br />B</span>     Bohr magneton
eV                 eV                                    Electronvolt
mev                meV                                   Electronvolt
keV                keV                                   Electronvolt
MeV                MeV                                   Electronvolt
GeV                GeV                                   Electronvolt
TeV                TeV                                   Electronvolt
J/mol              J/mol                                 Joule per mole
J.mol-1            J&sdot;mol<sup>−1</sup>               Joule per mole
kJ.mol-1           kJ&sdot;mol<sup>−1</sup>              Joule per mole
kJ/mol             kJ/mol                                Joule per mole
MJ.mol-1           MJ&sdot;mol<sup>−1</sup>              Joule per mole
MJ/mol             MJ/mol                                Joule per mole
GJ/mol             GJ/mol                                Joule per mole
GJ.mol-1           GJ&sdot;mol<sup>−1</sup>              Joule per mole
TJ.mol-1           TJ&sdot;mol<sup>−1</sup>              Joule per mole
TJ/mol             TJ/mol                                Joule per mole

== Numbers and phrases ==
pp                 pp                                    Page (paper)
ppb                ppb                                   Parts per billion                      1e-9
ppm                ppm                                   Parts per million                      1e-6
billiard           billiard                              Orders of magnitude (numbers)#1015     1e15
billion            billion                               1,000,000,000                          1e9
billionth          billionth                             1,000,000,000                          1e-9
billionths         billionths                            1,000,000,000                          1e-9
decilliard         decilliard                            Orders of magnitude (numbers)#1063     1e63
decillion          decillion                             Orders of magnitude (numbers)#1033     1e33
decillionth        decillionth                           Orders of magnitude (numbers)#1033     1e-33
decillionths       decillionths                          Orders of magnitude (numbers)#1033     1e-33
milliard           milliard                              1,000,000,000                          1e9
million            million                               Million                                1e6
millionth          millionth                             Million                                1e-6
millionths         millionths                            Million                                1e-6
nonilliard         nonilliard                            Orders of magnitude (numbers)#1057     1e57
nonillion          nonillion                             Orders of magnitude (numbers)#1030     1e30
nonillionth        nonillionth                           Orders of magnitude (numbers)#1030     1e-30
nonillionths       nonillionths                          Orders of magnitude (numbers)#1030     1e-30
octilliard         octilliard                            Orders of magnitude (numbers)#1051     1e51
octillion          octillion                             Orders of magnitude (numbers)#1027     1e27
octillionth        octillionth                           Orders of magnitude (numbers)#1027     1e-27
octillionths       octillionths                          Orders of magnitude (numbers)#1027     1e-27
quadrilliard       quadrilliard                          Orders of magnitude (numbers)#1027     1e27
quadrillion        quadrillion                           Orders of magnitude (numbers)#1015     1e15
quadrillionth      quadrillionth                         Orders of magnitude (numbers)#1015     1e-15
quadrillionths     quadrillionths                        Orders of magnitude (numbers)#1015     1e-15
quintilliard       quintilliard                          Orders of magnitude (numbers)#1033     1e33
quintillion        quintillion                           Orders of magnitude (numbers)#1018     1e18
quintillionth      quintillionth                         Orders of magnitude (numbers)#1018     1e-18
quintillionths     quintillionths                        Orders of magnitude (numbers)#1018     1e-18
septilliard        septilliard                           Orders of magnitude (numbers)#1045     1e45
septillion         septillion                            Orders of magnitude (numbers)#1024     1e24
septillionth       septillionth                          Orders of magnitude (numbers)#1024     1e-24
septillionths      septillionths                         Orders of magnitude (numbers)#1024     1e-24
sextilliard        sextilliard                           Orders of magnitude (numbers)#1039     1e39
sextillion         sextillion                            Orders of magnitude (numbers)#1021     1e21
sextillionth       sextillionth                          Orders of magnitude (numbers)#1021     1e-21
sextillionths      sextillionths                         Orders of magnitude (numbers)#1021     1e-21
trilliard          trilliard                             Orders of magnitude (numbers)#1021     1e21
trillion           trillion                              Orders of magnitude (numbers)#1012     1e12
trillionth         trillionth                            Orders of magnitude (numbers)#1012     1e-12
trillionths        trillionths                           Orders of magnitude (numbers)#1012     1e-12

== Angles ==
%                  %                                     Percent                                ANGLE   0.01
percent            %                                     Percent                                ANGLE   0.01
per cent           %                                     Percent                                ANGLE   0.01
‰                  ‰                                     Per mil                                ANGLE   1e-3
per mil            ‰                                     Per mil                                ANGLE   1e-3
per mill           ‰                                     Per mil                                ANGLE   1e-3
per mille          ‰                                     Per mil                                ANGLE   1e-3
permil             ‰                                     Per mil                                ANGLE   1e-3
permill            ‰                                     Per mil                                ANGLE   1e-3
permille           ‰                                     Per mil                                ANGLE   1e-3
°                  °                                     Degree (angle)                         ANGLE   pi/180
deg                °                                     Degree (angle)                         ANGLE   pi/180
'                  ′                                     Minute of arc                          ANGLE   pi/10800
′                  ′                                     Minute of arc                          ANGLE   pi/10800
arcmin             ′                                     Minute of arc                          ANGLE   pi/10800
arcminute          ′                                     Minute of arc                          ANGLE   pi/10800
"                  ″                                     Second of arc                          ANGLE   pi/648000
″                  ″                                     Second of arc                          ANGLE   pi/648000
arcsec             ″                                     Second of arc                          ANGLE   pi/648000
arcsecond          ″                                     Second of arc                          ANGLE   pi/648000

]=]

-- If val has "|long scale=on" the following definitions are used
-- (then, if not found here, the normal definitions are used).
-- Unit code       Symbol                                Link                                   Flags/Scale
local builtin_units_long_scale = [=[

== Long scale numbers and phrases ==
billion            billion                               Orders of magnitude (numbers)#1012     1e12
billionth          billionth                             Orders of magnitude (numbers)#1012     1e-12
billionths         billionths                            Orders of magnitude (numbers)#1012     1e-12
decillion          decillion                             Orders of magnitude (numbers)#1060     1e60
decillionth        decillionth                           Orders of magnitude (numbers)#1060     1e-60
decillionths       decillionths                          Orders of magnitude (numbers)#1060     1e-60
nonillion          nonillion                             Orders of magnitude (numbers)#1054     1e54
nonillionth        nonillionth                           Orders of magnitude (numbers)#1054     1e-54
nonillionths       nonillionths                          Orders of magnitude (numbers)#1054     1e-54
octillion          octillion                             Orders of magnitude (numbers)#1048     1e48
octillionth        octillionth                           Orders of magnitude (numbers)#1048     1e-48
octillionths       octillionths                          Orders of magnitude (numbers)#1048     1e-48
quadrillion        quadrillion                           Orders of magnitude (numbers)#1024     1e24
quadrillionth      quadrillionth                         Orders of magnitude (numbers)#1024     1e-24
quadrillionths     quadrillionths                        Orders of magnitude (numbers)#1024     1e-24
quintillion        quintillion                           Orders of magnitude (numbers)#1030     1e30
quintillionth      quintillionth                         Orders of magnitude (numbers)#1030     1e-30
quintillionths     quintillionths                        Orders of magnitude (numbers)#1030     1e-30
septillion         septillion                            Orders of magnitude (numbers)#1042     1e42
septillionth       septillionth                          Orders of magnitude (numbers)#1042     1e-42
septillionths      septillionths                         Orders of magnitude (numbers)#1042     1e-42
sextillion         sextillion                            Orders of magnitude (numbers)#1036     1e36
sextillionth       sextillionth                          Orders of magnitude (numbers)#1036     1e-36
sextillionths      sextillionths                         Orders of magnitude (numbers)#1036     1e-36
trillion           trillion                              Orders of magnitude (numbers)#1018     1e18
trillionth         trillionth                            Orders of magnitude (numbers)#1018     1e-18
trillionths        trillionths                           Orders of magnitude (numbers)#1018     1e-18

]=]

return { builtin_units = builtin_units, builtin_units_long_scale = builtin_units_long_scale }