GNU Units
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 conversion.
I used to think we could use a hash table for this kind of stuff. It is faster of course but you need to account for all sort of conversion, even the crazy ones like Lightyear to feet’s, for instant. With the graph, I think I could just throw everything in it. No matter how crazy the conversion is, if there is a path, you will get it!<p>How does GNU unit get the conversion tables to bootstrap, does anybody know?