Subject: Re: [boost] Using units prefix dynamically to get the appropriate prefix for the size of the value?
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2009-11-23 10:45:18
> -----Original Message-----
> From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]] On
> Steven Watanabe
> Sent: Monday, November 23, 2009 2:57 PM
> To: boost_at_[hidden]
> Subject: Re: [boost] Using units prefix dynamically to get the appropriate
prefix for the size
> of the value?
> Paul A. Bristow wrote:
> > I'd like to use the units library prefix (k, M, G ...) system, but I'd
> > like to determine the prefix dynamically (automatically) depending on the
> > For example, if I have a length of 12300 m I'd like an output of "12.3 km"
> > if my length is 0.0123 m, I'd like an output of "12.3 mm".
> > I can't see how to do this (and including the correct length unit of m or
> > of course).
> > Suggestions?
> There is no way to do this right now. Currently the
> output operator completely separates printing the
> value from printing the unit.
> Feel free to add a feature request in trac.
Ticket #3660 (new Feature Requests)
> I can't think of a good name for a stream manipulator off hand.
The least problem? ;-)
PS If you think this might be 'an exercise for the student' - give me some hints
on how you think it might be done, and I'll have a go at it.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk