I haven’t looked at the code for this but somehow I think the conversion problem is very similar to a graph search. If you build a graph in which the vertices are the units and the edges are compatible convert scales, you can use this graph with say, BFS to find the right traversal path. Multiplying the scales would get you the result converting from a unit to another. Or, dividing would give you the reversed convers…
GNU Units
11–20 of 117 posts
Re: GNU Units
#12I haven’t looked at the code for this but somehow I think the conversion problem is very similar to a graph search. If you build a graph in which the vertices are the units and the edges are compatible convert scales, you can use this graph with say, BFS to find the right traversal path. Multiplying the scales would get you the result converting from a unit to another. Or, dividing would give you the reversed convers…
Re: GNU Units
#13I haven’t looked at the code for this but somehow I think the conversion problem is very similar to a graph search. If you build a graph in which the vertices are the units and the edges are compatible convert scales, you can use this graph with say, BFS to find the right traversal path. Multiplying the scales would get you the result converting from a unit to another. Or, dividing would give you the reversed convers…
Wouldn't the most sensible option just be too have the SI units at the center and everything else heaving a conversion edge to that? While intriguing, there is probably no need to make that graph any denser.
Re: GNU Units
#14 You have: A / m
You want: ?
H_FIELD B_FIELD / (mu0/mu0_SI)
MAGNETIZATION MAGNETIC_DIPOLE_MOMENT / VOLUME
Oe oersted
oe Oe
oersted gauss / mu0
The units definitions file also contains many interesting facts, here's an excerpt: A ! # The ampere, symbol A, is the SI unit of electric current.
ampere A # It is defined by taking the fixed numerical value of the
amp ampere # elementary charge, e, to be 1.602 176 634 * 10^-19 when
# expressed in the unit C, which is equal to A*s.
#
# The previous definition was the current which produces a
# force of 2e-7 N/m between two infinitely long wires a meter
# apart. This definition was difficult to realize accurately.
#
# The ampere is actually realized by establishing the volt and
# the ohm, since A = V / ohm. These measurements can be done
# using the Josephson effect and the quantum Hall effect,
# which accurately measure voltage and resistance, respectively,
# with reference to two fixed constants, the Josephson
# constant, K_J=2e/h and the von Klitzing constant, R_K=h/e^2.
# Under the previous SI system, these constants had official
# fixed values, defined in 1990. This created a situation
# where the standard values for the volt and ohm were in some
# sense outside of SI because they depended primarily on
# constants different from the ones used to define SI. After
# the revision, since e and h have exact definitions, the
# Josephson and von Klitzing constants will also have exact
# definitions that derive from SI instead of the conventional
# 1990 values.
#
# In fact we know that there is a small offset between the
# conventional values of the electrical units based on the
# conventional 1990 values and the SI values. The new
# definition, which brings the practical electrical units back
# into SI, will lead to a one time change of +0.1ppm for
# voltage values and +0.02ppm for resistance values.
#
# The previous definition resulted in fixed exact values for
# the vacuum permeability (mu0), the impedance of free space
# (Z0), the vacuum permittivity (epsilon0), and the Coulomb
# constant. With the new definition, these four values are
# subject to experimental error.Re: GNU Units
#15Earlier quoted context omitted.
Wouldn't the most sensible option just be too have the SI units at the center and everything else heaving a conversion edge to that? While intriguing, there is probably no need to make that graph any denser.
Then how do you deal with non-SI units, like money?
Re: GNU Units
#16Earlier quoted context omitted.
Wouldn't the most sensible option just be too have the SI units at the center and everything else heaving a conversion edge to that? While intriguing, there is probably no need to make that graph any denser.
Then how do you deal with non-SI units, like money?
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.
Re: GNU Units
#17I haven’t looked at the code for this but somehow I think the conversion problem is very similar to a graph search. If you build a graph in which the vertices are the units and the edges are compatible convert scales, you can use this graph with say, BFS to find the right traversal path. Multiplying the scales would get you the result converting from a unit to another. Or, dividing would give you the reversed convers…
Wouldn't the most sensible option just be too have the SI units at the center and everything else heaving a conversion edge to that? While intriguing, there is probably no need to make that graph any denser.
Re: GNU Units
#18I haven’t looked at the code for this but somehow I think the conversion problem is very similar to a graph search. If you build a graph in which the vertices are the units and the edges are compatible convert scales, you can use this graph with say, BFS to find the right traversal path. Multiplying the scales would get you the result converting from a unit to another. Or, dividing would give you the reversed convers…
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
Re: GNU Units
#19Earlier quoted context omitted.
Wouldn't the most sensible option just be too have the SI units at the center and everything else heaving a conversion edge to that? While intriguing, there is probably no need to make that graph any denser.
Then how do you deal with non-SI units, like money?
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.
Re: GNU Units
#20(2016) Posted a few times recently Here's some more discussion 3 years ago: https://news.ycombinator.com/item?id=25657311