|
Boost : |
From: james.jones_at_[hidden]
Date: 2007-02-09 11:29:27
From: Andreas Harnack <ah.boost.02_at_[hidden]>
> 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.
If exponents of 4 are the highest you've seen, shouldn't you consider the size of (2*3*5*7*11*13*17)^4, which requires 76 bits? Also, I may want to extend the list - some people have requested a "money" unit, for example, which would be assigned the value 19 in your system. Then I can't even represent all powers of 3. I suspect this idea, while clever, does not cover the problem domain sufficiently well to be superior to lists.
-
James Jones Administrative Data Mgmt.
Webmaster 375 Raritan Center Pkwy, Suite A
Data Architect Edison, NJ 08837
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk