From: Kevin Olbrich Date: 2006-08-24T01:15:05+09:00 Subject: Re: Ruby Units On Thursday, August 24, 2006, at 12:04 AM, Peter Vanbroekhoven wrote: >On 8/23/06, Kevin Olbrich wrote: >> Hey, amazing all the interesting stuff that pops up when you know where >> to look for it. >> >> After a 15 minute look, I can see some issues with the current version >> of Units in facets. >> >> 1. It doesn't implement Comparable. >> 1.cm < 2.m #=> throws an exception in Facets >> "1 cm".unit < "2 m".unit #=> returns true in ruby-units >> >> 2. The binary prefixes are incorrect (at least in the RDoc). They >> should be like 'kibi = 2**10' and 'mebi = 2**20'. > >I have no problem adding these. However, personally, I don't like >kibibyte and prefer kilobyte, and I expect I'm not alone. Facets' >units.rb is flexible enough to allow kibi = 2**10 and kilo = 10**3 >(following the IEC convention, >http://en.wikipedia.org/wiki/Binary_prefix) next to kilo = 2**10. The >only issue is which to make the default. My only suggestion is to name the binary prefixes correctly, and allow people to use the SI ones as well. I've tried to follow the standards when possible, even if I don't like Mebibits. > >> 3. Facet Units doesn't seem to do temperature conversions. Maybe it >> does, but I can't find any documentation on it. > >It doesn't as temperature conversions are ill-defined. As you know, >both absolute temperatures and temperature differences have the same >unit. Any operation on two temperatures expressed in different units >cannot be correct for absolute temperatures and temperature >differences. This is an inherent problem, so we had three choices: do >no conversions, use the conversion for absolute temperatures, or use >the conversion for temperature differences. We chose the first of >these three. We're open to additional ideas on this. My solution to this was to scale the temperature units by size (as a differential) except in the case where the conversion was from one temperature unit to another. In that case, it does the correct conversion. When temperatures are used in compound units, they never represent an absolute temperature value. If you do the absolute conversion when they are the only units there, then you can do proper temperature math. Although it appears that my solution has it's own problems. You can add/ subtract temperatures and the get the new absolute value, but you may want the differential value instead. I'll have to think about that one a bit more. _Kevin www.sciwerks.com -- Posted with http://DevLists.com. Sign up and save your mailbox.