boost.units converting double tp SI prefix

Hi, is there a way to use boost.units to convert a double automatically to a SI unit prefix, e.g. 10e-3 to 10m or 10e3 to 10k ?? The value isn't know at compile time, so the decision has to be done on runtime. Thanks, Olaf

AMDG Olaf Peter wrote:
is there a way to use boost.units to convert a double automatically to a SI unit prefix, e.g. 10e-3 to 10m or 10e3 to 10k ?? The value isn't know at compile time, so the decision has to be done on runtime.
There is not such a facility. There will soon be support for printing things like 1.0 km instead of 1000 m, but formatting of raw numbers is somewhat beyond the scope of the library. In Christ, Steven Watanabe

-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Steven Watanabe Sent: Friday, March 12, 2010 7:23 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] boost.units converting double tp SI prefix
AMDG
Olaf Peter wrote:
is there a way to use boost.units to convert a double automatically to a SI unit prefix, e.g. 10e-3 to 10m or 10e3 to 10k ?? The value isn't know at compile time, so the decision has to be done on runtime.
There is not such a facility. There will soon be support for printing things like 1.0 km instead of 1000 m, but formatting of raw numbers is somewhat beyond the scope of the library.
But I think that you can create your own unit (and quantity) easily,
and then you *can* use the very useful auto prefixing system Steven has devised.
For example for show this, I've created a entirely useless 'thing' type - dimensionless of course.
It could be widget count, (or indeed a unit of currency) with a name and symbol.
struct thing_base_unit : boost::units::base_unit
participants (3)
-
Olaf Peter
-
Paul A. Bristow
-
Steven Watanabe