 # Boost :

From: Jan Langer (jan_at_[hidden])
Date: 2003-10-16 16:46:28

Jan Van Dijk wrote:
> This is not as clear-cut as it seems. Think about logarithmic units. As you
> know such units are defined as the N-log (typically 2 or 10) of the ratio of
> the value P, say, and a reference Pref. As an example, take the decibel:
>
> power in dB = 10log(P/Pref).
>
> [I forgot Pref, but that does not matter]. Anyway, the result is that
> combining two power sources of both 0dB yield 3dB: "0+0=3".
>
> If the library is supposed to do not only dimensional analysis, but also unit
> conversion or even arithmetics on (physical) quantities, it should be taught
> that in the above case the P's should be added, rather than the
> representations of P in the logarithmic units. The units should be marked as
> logarithmic, so that distributivity (val1*u+val2*u=(val1+val2)*u) is no
> longer assumed.
>
> This is probably outside the scope of the proposed library.

yes. but wouldnt it be possible to write a class doing calculations with
logarithmic values. i cannot give any details how this could be done,
because one has to carefully think about the desired semantics, but i
think its possible and then you can do something like

quantity <double, power> p1 = 2 * watt;
quantity <dB, power> p2 = dB (3) * watt;

quantity <double, power> p3 = p1 + p2; // approx. 4 watt

this would work if double operator + (double, dB) works.
jan

```--
jan langer ... jan_at_[hidden]
"pi ist genau drei"
```