Boost logo

Boost :

Subject: [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 06:08:54


I'd like to use the units library prefix (k, M, G ...) system, but I'd really
like to determine the prefix dynamically (automatically) depending on the value.

For example, if I have a length of 12300 m I'd like an output of "12.3 km" but
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 meter
of course).

Suggestions?

Paul

---
Paul A. Bristow
Prizet Farmhouse
Kendal, UK   LA8 8AB
+44 1539 561830, mobile +44 7714330204
pbristow_at_[hidden]

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