If I define a value in bytes and print it:
using namespace boost::units;
using namespace boost::units::information;
quantity<info> nbytes = 1234 * bytes;
std::cout << nbytes << std::endl; // 1234 B
Ok, that's fine, but what I really want is "1.234 kB". There's an auto-scaling prefix for that:
std::cout << engineering_prefix << nbytes << std::endl; // 9.872 kb
It printed in units of the base unit, bits. How can I get it to auto-scale, but preserve the base unit of bytes?
One way (the only way I've found so far) is to define my own base unit that does not scale down to bits. It appears the implementation of
do_print_prefixeddeep in the bowels of Boost.Unit unscales the value and there is no way to stop it.