Boost logo

Boost :

Subject: [boost] [units] inconvent printing of composite scaled units
From: Matthias Schabel (boost_at_[hidden])
Date: 2011-01-03 15:41:08


> great, it works, using the CGS example, if I define:
>
> namespace boost{namespace unit{
> namespace si{
> typedef scaled_base_unit<boost::units::si::second_base_unit,
> scale<10, static_rational<-15> > > femtosecond_base_unit;
> typedef femtosecond_base_unit::unit_type femtosecond_unit;
> static const femtosecond_unit femtosecond, femtoseconds;
> }
> }}
>
> then
>
> cout << 3.*si::meter/si::femtosecond << endl; // prints 3 m fs^-1
>
> while
>
> cout << 3.*si::meter/(si::femto*si::second) << endl; //print 3 P(m
> s^-1), notice the ugly P (for Peta)
>
> this gives better control on the intended output (at least).
>
> (Unfortunately this operation doesn't work 3.*si::femtosecond +
> 2.*(si::femto*si::second) )

I'm guessing that this is an issue of mixing scaled and unscaled quantities...
It should probably work, though, since si::femto*si::second should really return
the scaled unit you define manually above. I'll look into it, though it may be a
while.

Matthias


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