How does GNU unit get the conversion tables to bootstrap, does anybody know?
How does GNU unit get the conversion tables to bootstrap, does anybody know?
it's just a finite-dimensional vector space over ℚ
https://en.wikipedia.org/wiki/Dimensional_analysis#Mathemati...
the conversion tables are in /usr/share/units/definitions.units (or previously /usr/share/misc/units.dat)
they are the result of many years of careful scholarship by adrian mariano
The physical kind is a point in an N-dimensional rational space of exponents of base units, such as Mass * Distance ^2 * Time^-2 or (1,2,-2) for energy (maybe with some carry over ^0s for unused slots of a >3D meta-type space). Additive (like add, subtract, compare, and convert) are only meaningful at the same point in that lattice. If you are interested in learning more, this is all a part of dimensional analysis: https://en.wikipedia.org/wiki/Dimensional_analysis .
Even the dimensionality of that rational exponent space (the "unit system", if you will) is more of convenience / convention than fundamental. https://en.wikipedia.org/wiki/Planck_units clobber most things away leaving only 1 dimension (and a tendency for complex rational exponents). Meanwhile, the SI unit system is very "dimension promiscuous" (mass, length, time, electric current, temperature, amount of substance, luminous intensity) [1] to avoid non-integer exponents (but you cannot really forever since as soon as some formula has some square some solution of it has some root that probably gets you a 1/2 exponent).
There are some situations with not purely "conversion factor" scale offsets like thermal units (e.g. Celsius to Fahrenheit) that people often describe in math-ese as "affine conversions". Something like GNU Units attends these things, but they are kind of "conversion only" orphan step-children more than "real" types which "compose better". In physics formulae one will often only care about delta-Temperature, not levels, for example.
EDIT: The implicit creation of a potentially brand new type any time you multiply | divide two extant things is, incidentally, why you need either a dynamic or a very powerful static type system to express these things.
[1] https://en.wikipedia.org/wiki/International_System_of_Units
For currency conversion, it's a lot more tricky because there's many ways to convert. Eg; if I want to go from CHF to USD there's a lot of CHF->USD volume and there are market rates for that exact conversion. But between eg; SGD (singapore dollar) and Peruvian Soles (PEN) the market is a lot smaller so it may be actually beneficial to do SGD -> USD -> PEN.
Typically this means ingesting a feed of real time prices + any fees and then doing a limited-hop graph traversal.
the base unit is the us dollar
this is arguably incorrect but inarguably useful
from the man page:
> The units program database includes currency exchange rates and prices for some precious metals. Of course, these values change over time, sometimes very rapidly, and ‘units’ cannot provide real-time values. To update the exchange rates, run ‘units_cur’, which rewrites the file containing the currency rates, typically ‘/var/lib/units/currency.units’ or ‘/usr/local/com/units/currency.units’ on a Unix-like system or ‘C:\Program Files (x86)\GNU\units\definitions.units’ on a Windows system.
US Dollars would be connected to US Cents in the graph, and Pounds Sterling and New Pence would be connected to each other too, but those two subgraphs would be entirely disconnected from each other and from any SI unit like distance or mass.
What I like about the graph solution is that you don’t have to use SI or base unit at all! If your graph has km -> m, now you add (updating your graph) for m -> feet, you could traverse from km -> feet. Later on, you can add nautical mile -> feet, using this graph you could basically get km -> nautical mile if you need to.