Boost logo

Boost :

From: Reece Dunn (msclrhd_at_[hidden])
Date: 2006-06-09 03:56:49

Carlo Wood wrote:
> On Thu, Jun 08, 2006 at 08:59:36PM +0100, Reece Dunn wrote:
> > /** @brief mass */
> >
> > typedef base_unit< si_tag, mass, prefix::kilo > kilogram;
> >
> > typedef scaled_unit< kilogram, prefix::kilo > kg;
> > typedef scaled_unit< kilogram, prefix::base > g;
> > typedef scaled_unit< kilogram, prefix::milli > mg;
> Surely you mean,
> typedef base_unit< si_tag, mass, prefix::base > kilogram;
> typedef scaled_unit< kilogram, prefix::base > kg;
> typedef scaled_unit< kilogram, prefix::milli > g;

No. The reason is that kg is *kilo*gram. So:

   kg = 1x10^3 g
   g = 1x10^0 g

Also note that Newtons is expressed in terms of kilograms
as well, so the type system/internal logic will know that:

   mass = 1kg
   speed = 1s
   distance = 1m

results in:

   force = 1N

This was a conscious design on my part: the prefixes should
*always* follow the SI unit terminology for SI units. That is
why prefix::kilo is specified in the base unit -- so the program
knows it needs to convert the unit if using grams.

If g were to have prefix::milli, it would have a symbol of mg
which makes no rational sense.

- Reece
Express yourself instantly with MSN Messenger! Download today it's FREE!

Boost list run by bdawes at, gregod at, cpdaniel at, john at