|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r66838 - trunk/libs/math/example
From: pbristow_at_[hidden]
Date: 2010-11-29 05:21:59
Author: pbristow
Date: 2010-11-29 05:21:56 EST (Mon, 29 Nov 2010)
New Revision: 66838
URL: http://svn.boost.org/trac/boost/changeset/66838
Log:
Limit use of max_digits10 to MSVC 10
Text files modified:
trunk/libs/math/example/geometric_examples.cpp | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
Modified: trunk/libs/math/example/geometric_examples.cpp
==============================================================================
--- trunk/libs/math/example/geometric_examples.cpp (original)
+++ trunk/libs/math/example/geometric_examples.cpp 2010-11-29 05:21:56 EST (Mon, 29 Nov 2010)
@@ -62,9 +62,8 @@
{
cout <<"Geometric distribution example" << endl;
cout << endl;
- cout.precision(std::numeric_limits<double>::max_digits10);
- // gives all potentially significant digits for the type, here double.
- cout.precision(4);
+
+ cout.precision(4); // But only show a few for this example.
try
{
//[geometric_eg1_2
@@ -156,7 +155,12 @@
So in Boost.Math the equivalent is
*/
geometric g05(0.5); // Probability of success = 0.5 or 50%
- cout.precision(numeric_limits<double>::max_digits10); // Display all potentially significant digits.
+ // Output all potentially significant digits for the type, here double.
+#if (_MSC_VER >= 1600)
+ cout.precision(std::numeric_limits<double>::max_digits10);
+#else
+ cout.precision(2 + (boost::math::policies::digits<double, boost::math::policies::policy<> >() * 30103UL) / 100000UL);
+#endif
cout << cdf(g05, 0.0001) << endl; // returns 0.5000346561579232, not exact 0.5.
/*`To get the R discrete behaviour, you simply need to round with,
for example, the `floor` function.
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