5 ms·
Then how do you deal with non-SI units, like money?
by mrbonner 3y ago
Then how do you deal with non-SI units, like money?
- simplicio 3y agoJust pick a unit as the "standard" for that type of quantity.
- alfalfasprout 3y agoNotice how money isn't handled (at least per the examples) by GNU Units. Because currency (and fungible financial instruments in general) have variable exchange rates. 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.
- mrbonner 3y agoIt is interesting because I see a file `currency.units` in the source distribution. It has the list of all countries' currencies normalized to USD. If Units doesn't deal with currency, why does it maintain this conversion file? And, I agree that the exchange rate varies day to day. But, this may provide an estimate conversion.
- kragen 3y agomoney is handled by gnu units 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.
- seabass-labrax 3y agoYou can't really convert units of money to any other units, so I'm not convinced of the utility of money conversion in this kind of tool. 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.
- progman32 3y agoIt's useful for some practical conversions like fuel efficiency calculations. I think in USD per mile and it's handy to be able to directly take CAD/liter and l/km for my trips to Canada.
- tadfisher 3y agoMoney (currency, really) is a whole forest of units with bespoke scales, arithmetic, and market-driven conversion logic. If you are converting money to other units with a library, you are almost certainly doing it wrong, or are operating at a level of abstraction much higher than my puny brain can fathom.
- qbrass 3y agoConvert to USD then back. Which is what Units does.