Module:Val/units/doc: Difference between revisions
Content deleted Content added
Caleb Cooper (talk | contribs) |
Caleb Cooper (talk | contribs) |
||
Line 180:
Val's sorting scale factor is for comparison to other Val units that might be sorted with it.
Where [[Wikipedia:Help:Sorting|Sorting]] is done on the wiki, it is done in [[Wikipedia:Help:table#Sortable tables|sortable tables]].
Val entries in a sortable table will need a fourth field sorting flag. It can be a number, an equation, or an <kbd>SI</kbd>, but it flags the same function: a wikitable sorting "scale".
Line 192:
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 [[Wikipedia:system of units|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 <kbd>billion</kbd>, symbol <kbd>billion</kbd>, link [[Wikipedia:1,000,000,000|1,000,000,000]], and scale <kbd>1e9</kbd> ({{val|1|e=9}}). After the following entry is saved to the database
<pre>
billion billion 1,000,000,000 1e9
Line 204:
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 [[Wikipedia:SI prefix|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 <code>μ</code> in your symbol, for your "easy to type" unit code, {{key|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 [[Wikipedia:e notation|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.
<pre>
m [[Wikipedia:Metre|m]] SI
cm [[Wikipedia:Centimetre|m]] SI
dam [[Wikipedia:Decametre|m]] SI
dm [[Wikipedia:Decimetre|m]] SI
hm [[Wikipedia:Hectometre|m]] SI
km [[Wikipedia:Kilometre|m]] SI
Mm [[Wikipedia:Megametre|m]] SI
mm [[Wikipedia:Millimetre|m]] SI
um [[Wikipedia:Micrometre|µm]] 1/1000000
µm [[Wikipedia:Micrometre|m]] SI
nm [[Wikipedia:Nanometre|m]] SI
pm [[Wikipedia:Picometre|m]] SI
</pre>
| |||