On Thursday, August 24, 2006, at 1:19 PM, Hal Fulton wrote:
>Paul Lutus wrote:
>> Calamitas wrote:
>>
>>
>>>I've not addressed the temperature problem as I'm still not very happy
>>>with it. My current opinion is that maybe temperature conversion
>>>should be done by separate methods, and only Kelvin should be allowed
>>>in the whole units machinery.
>>
>>
>> If you only have Kelvin and no other temperature units, no
>>conversions can
>> be made.
>
>Since he says "in the machinery," I think he means internally it would
>all be in Kelvin.
>
>I'm assuming every measure has a "default" unit (e.g., meter) and that
>all conversions go there first.
>
>Maybe not -- but that's how I'd do it. Convert feet to furlongs by first
>converting feet to meters and then meters to furlongs. That way there
>are fewer conversion factors required. Of course, significant digits
>become a problem, but I have to assume the library user worries about
>that.
>
>
>Hal
>

Yes, you need to do a lot of conversion to base units to make things  
work nicely.

BTW...

def test_ideal_gas_law
    p = Unit "100 kPa"
    v = Unit "1 m^3"
    n = Unit "1 mole"
    r = Unit "8.31451 J/mol*degK"
    t = ((p*v)/(n*r)).to("tempF")
    assert_in_delta 21189.2,t.to_f, 0.1
end

p t.to_s #=> '21189.2 degF'

This test passes.

Note the use if the 'tempF' unit for conversion.  This unit doesn't  
really exist in ruby-units, it just tells the conversion routine to do  
the proper math to convert the internal differential temperature units  
into an absolute one.

This seems like an acceptable compromise to me.

_Kevin
www.sciwerks.com

-- 
Posted with http://DevLists.com.  Sign up and save your mailbox.