$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Andreas Harnack (ah.boost.02_at_[hidden])
Date: 2007-02-09 09:10:57
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.
Andreas