
9 Jun
2006
9 Jun
'06
8:57 a.m.
Andy Little <andy <at> servocomm.freeserve.co.uk> writes:
Consider the calculation 1 km * 1 millisecond.
The external units approach
1 * km * 1 * millisecond, which expanding the constants would be
1 * 1000. * 1 * .001
In pqs the internal calculation at runtime is simply
1. * 1.
The type of the result encodes the calculation 1000 * .001 as plus<3,-3>::value in the unit of the result.
BTW, I think this is an excellent example. It shows clearly how keeping track of the units at compile time would benefit the user, and also gives an idea of how it works. -- Leland