Boost logo

Boost :

From: Hugo Duncan (hugoduncan_at_[hidden])
Date: 2003-10-16 18:19:52

Jan Langer <jan_at_[hidden]> wrote:

> Hugo Duncan wrote:

>>>> Agreed, but how do you use a unit such as BTU which is not defined
>>>> in terms of units of fundamental dimensions?
>>> how about:
>>> quantity <double, energy> const btu = 1055 * joules;
>> energy is not a fundamental dimension.
>> joules = kg·m2/s2 [ M L^2 T^-2 ]
> yes of course. but why shouldn't it be used as the dimension of a
> quantity?

I think my issue is based on the assumption that per (quantity)
instance unit information would be possible, ie. that there is
not necessarily a "stored" unit for each dimension. This
then raises issues of expressions such as

   quantity<double,power,watts> p; // stored units
   quantity<double,energy> e = 10 * btu; // runtime units
   quantity<double,time> t = 1 * min; // runtime units

   p = e * t; // need to convert btu/min to watts

The expressions can obviously get arbirarily complex so it is
not possible to define all required conversions (eg btu/min to watts)
externally to the expressions where they are used.

Reasons for runtime units include
   i) allowing user to input in arbitrary units
  ii) facilitate financial calculations (where inputs have to
      be keep in their input currency(==unit))


Boost list run by bdawes at, gregod at, cpdaniel at, john at