Boost logo

Boost :

From: Martin Bonner (Martin.Bonner_at_[hidden])
Date: 2007-02-09 09:21:01


----Original Message----
From: boost-bounces_at_[hidden]
[mailto:boost-bounces_at_[hidden]] On Behalf Of Andreas Harnack
Sent: 09 February 2007 14:11 To: boost_at_[hidden]
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_at_[hidden]
www.pi-shurlok.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk