Hi,
I’m trying to run the example given in
http://www.boost.org/doc/libs/1_62_0/doc/html/boost_units/Examples.html#boos..., and the result is puzzling.
$ cat foo2.cc
#include <iostream>
#include
#include
using namespace std;
using boost::units::binary_prefix;
using boost::units::engineering_prefix;
using boost::units::no_prefix;
using boost::units::symbol_format;
using boost::units::quantity;
using boost::units::information::byte_base_unit;
int main()
{
cout << BOOST_VERSION << endl;
// Don't forget that the units name or symbol format specification is persistent.
cout << symbol_format; // Resets the format to the default symbol format.
quantity b = 2048. * byte_base_unit::unit_type();
cout << b << endl;
cout << engineering_prefix << b << endl; // 2.048 kb
cout << symbol_format << binary_prefix << b << endl; // "2 Kib"
}
$ g++-6 foo2.cc -o foo2
$ ./foo2
106200
2048 B
16.384 kb
16 Kib
What am I doing wrong?
Note that there are a couple of issues in the example as given:
- there should not be any endl after cout << symbol_format;
- using ‘\n’ instead of endl, too many people seem to believe that
std::endl is the normal way to end the lines
- it would be nice to provide all the needed includes