
----Original Message---- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Andreas Harnack Sent: 09 February 2007 14:11 To: boost@lists.boost.org Subject: Re: [boost] formal review request : mcs::units
Michael Walter wrote:
How would you store the products? I don't really like the idea of unintuitive limits on the composition of base units (e.g. you can represent 2^31, but not 19^31)
I might have been a bit imprecise here, so please consider:
const unsigned int Time = 2; const unsigned int Length = 3; const unsigned int Mass = 5; const unsigned int Current = 7; const unsigned int Temp = 11; const unsigned int Amount = 13; const unsigned int Intensity = 17;
template <unsigned int N, unsigned int D=1> struct Rational { ... };
typedef Rational<Time> time; typedef Rational<Length> length; typedef Rational<Mass*Length,Times*Times> force; typedef Rational<Mass*Length*Length,Times*Times> energy;
quantity<energy, double> e;
so the representation of energy would be just 5*3*3/2*2 = 45/4.
You're right, there is a computational limit, but I wouldn't expect to a see a dimension with the power of 31. Exponends of 4 are about the highest I've ever seen, and (2*3*5*7*11*13*17)^3 still fits in 57 bits, so we might want to use long or even long long unsigned ints, but that should be fine for most situations.
How would you deal with fractional powers of units? (The subject came up in the pqs/quan review, and it was clear they were significant to some people). -- Martin Bonner Project Leader PI SHURLOK LTD Telephone: +44 1223 441434 / 203894 (direct) Fax: +44 1223 203999 Email: martin.bonner@pi-shurlok.com www.pi-shurlok.com