Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext
Floating-Point Precision

boost::cnv::strtol cnv;

BOOST_TEST(  "12.3" == convert<string>(12.3456, cnv(arg::precision = 1)).value());
BOOST_TEST( "12.35" == convert<string>(12.3456, cnv(arg::precision = 2)).value());
BOOST_TEST("12.346" == convert<string>(12.3456, cnv(arg::precision = 3)).value());

BOOST_TEST(  "-12.3" == convert<string>(-12.3456, cnv(arg::precision = 1)).value());
BOOST_TEST( "-12.35" == convert<string>(-12.3456, cnv(arg::precision = 2)).value());
BOOST_TEST("-12.346" == convert<string>(-12.3456, cnv(arg::precision = 3)).value());


PrevUpHomeNext