Boost logo

Boost Users :

Subject: [Boost-users] [units] inconvent printing of composite scaled units
From: alfC (alfredo.correa_at_[hidden])
Date: 2010-07-23 23:09:37


In the following program,
a quantity of fempto*second unit is printed as
0 fs (correctly)
but a quantity of composed units composed meter over femptosecond is
printed as
P( m s^-1)
I was expecting:
m fs^-1

At first I though it was a bug, where the P is coming from? where the
parenthesis is coming from?, but then I realized that P stands for
Peta (10e15).

is there any workaround? For example an easy way to define fs_unit in
some other way such that the f (fempto) keeps attached to the s
(second).

Below is the example code

#include<boost/units/systems/si.hpp>
#include<boost/units/make_scaled_unit.hpp>
#include<iostream>
using namespace boost::units;
using namespace std;
int main(){
        typedef make_scaled_unit<si::time, scale<10, static_rational<-15> >
>::type fs_unit;
        quantity<fs_unit> t(1.*si::second);
        quantity<si::length> l(1.*si::meter);
        quantity<divide_typeof_helper<si::length, fs_unit>::type > v = l/t;
        cout << t << endl; // prints 1e+15 fs
        cout << l << endl; // prints 1 m
        cout << v << endl; //prints 1e-15 P(m s^-1), notice the P
        return 0;
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net