Subject: Re: [boost] Using units prefix dynamically to get the appropriate prefix for the size of the value?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-11-23 11:07:05
Paul A. Bristow wrote:
>> 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? ;-)
But possibly the most important, since it's part of the
interface, while most of the rest is implementation details.
> 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.
Basically it would have to work something like:
if there is a top level prefix in the unit
strip it off and multiply the value by the appropriate constant
the prefix corresponds to log(value)/log(10) rounded down to the
nearest multiple of three. Look it up in some kind of table.
if it's way to big or small fall back on the default formatting with
The biggest hurdle is probably dynamic lookup of prefixes.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk