Closed astratto closed 11 years ago
I'll look into this, it's likely I missed some exponent behavior in the 0.1.6 release.
Great! At first I thought it was something related to conversions from A to A when the exponent is > 1.0, but there must be something wrong with the exponents in general:
2.0.0p247 :006 > 1.dl
=> #<Alchemist::Measurement:0x007f9155672058 @value=1.0, @unit_name=:l, @exponent=0.1>
2.0.0p247 :007 > 1.liter
=> #<Alchemist::Measurement:0x007f915567ab90 @value=1.0, @unit_name=:liter, @exponent=1.0>
2.0.0p247 :008 > 1.cup.to.dl.value
=> 0.2365882
2.0.0p247 :009 > 1.cup.to.liter.value
=> 0.2365882
This is partially fixed on master. I have some work ahead of me for making some changes but essentially there is a notable difference between #value and #to_f on Measurement. #value will give you the value unaffected by the exponent, whereas #to_f will be affected by the exponent. For example:
irb(main):009:0> 1.km.value
=> 1.0
irb(main):010:0> 1.km.to_f
=> 1000.0
Essentially to_f always gives you the value in terms of the base unit e.g. meter for kilometer. In the future I plan to make this more transparent, but that requires a few changes internally.
Hi! Maybe I'm missing something, but I get this weird conversion: