Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77626 - sandbox/big_number/libs/multiprecision/example
From: john_at_[hidden]
Date: 2012-03-29 08:28:32


Author: johnmaddock
Date: 2012-03-29 08:28:31 EDT (Thu, 29 Mar 2012)
New Revision: 77626
URL: http://svn.boost.org/trac/boost/changeset/77626

Log:
Extend examples using Paul Bristow's comments.
Text files modified:
   sandbox/big_number/libs/multiprecision/example/cpp_dec_float_snips.cpp | 10 ++++++++--
   1 files changed, 8 insertions(+), 2 deletions(-)

Modified: sandbox/big_number/libs/multiprecision/example/cpp_dec_float_snips.cpp
==============================================================================
--- sandbox/big_number/libs/multiprecision/example/cpp_dec_float_snips.cpp (original)
+++ sandbox/big_number/libs/multiprecision/example/cpp_dec_float_snips.cpp 2012-03-29 08:28:31 EDT (Thu, 29 Mar 2012)
@@ -17,12 +17,18 @@
    // Operations at fixed precision and full numeric_limits support:
    cpp_dec_float_100 b = 2;
    std::cout << std::numeric_limits<cpp_dec_float_100>::digits << std::endl;
- // We can use any C++ std lib function:
- std::cout << log(b) << std::endl; // print log(2)
+ // Note that digits10 is the same as digits, since we're base 10! :
+ std::cout << std::numeric_limits<cpp_dec_float_100>::digits10 << std::endl;
+ // We can use any C++ std lib function, lets print all the digits as well:
+ std::cout << std::setprecision(std::numeric_limits<cpp_dec_float_100>::max_digits10)
+ << log(b) << std::endl; // print log(2)
    // We can also use any function from Boost.Math:
    std::cout << boost::math::tgamma(b) << std::endl;
    // These even work when the argument is an expression template:
    std::cout << boost::math::tgamma(b * b) << std::endl;
+ // And since we have an extended exponent range we can generate some really large
+ // numbers here (4.0238726007709377354370243e+2564):
+ std::cout << boost::math::tgamma(cpp_dec_float_100(1000)) << std::endl;
    //]
 }
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk