Universal Units
-
Assuming there's merit in this, I think it would make an excellent article for someone with the know-how. Let's say you are writing a recipe program that can be used by people in various countries who use differing units of measurement. Converting gallons to liters or fahrenheit to celsius on the fly for displaying a recipe is easy enough that it's probably not worth worrying about performance, but what if someone wants to export a list of 100,000 recipes for someone using other units of measurement? With several ingredients and temperatures in each recipe, that results in a lot of conversions, and performance can become an issue. (The recipe list is just the first example that came to mind... There could be other situations with billions of such conversions.) I wonder if there is a way to pre-calculate a generic unit of, e.g., weight, which can then be used to extremely quickly find ounces, pounds, grams, troy ounces, grains, etc. without resorting to floating-point division, etc. I imagine this would fall under the umbrella of NP-complete problems, but since we're only dealing with a limited number of units it seems like it should be possible to find an optimal unit without waiting for a trillion years. :) Can this be done or has it been done? Or am I on the wrong track here?
-
Assuming there's merit in this, I think it would make an excellent article for someone with the know-how. Let's say you are writing a recipe program that can be used by people in various countries who use differing units of measurement. Converting gallons to liters or fahrenheit to celsius on the fly for displaying a recipe is easy enough that it's probably not worth worrying about performance, but what if someone wants to export a list of 100,000 recipes for someone using other units of measurement? With several ingredients and temperatures in each recipe, that results in a lot of conversions, and performance can become an issue. (The recipe list is just the first example that came to mind... There could be other situations with billions of such conversions.) I wonder if there is a way to pre-calculate a generic unit of, e.g., weight, which can then be used to extremely quickly find ounces, pounds, grams, troy ounces, grains, etc. without resorting to floating-point division, etc. I imagine this would fall under the umbrella of NP-complete problems, but since we're only dealing with a limited number of units it seems like it should be possible to find an optimal unit without waiting for a trillion years. :) Can this be done or has it been done? Or am I on the wrong track here?
generally, if a software is well released, and is MVC (model-view-Controlers) compliant, then the datas are always stored in the same way, in the same units. the problem of units is a matter of graphical rendering, so that affects only the UI (user interface)...