]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/math/example/big_seventh.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / math / example / big_seventh.cpp
index 62585ec0cda8b073ef8d334776ccd2679f8a056b..58c5590106ba9afc4b8c1600ab1179a083022ec5 100644 (file)
@@ -1,4 +1,3 @@
-
 // Use, modification and distribution are subject to the
 // Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt
@@ -40,38 +39,47 @@ To use these floating-point types and constants, we need some includes:
 #include <iostream>
 #include <limits>
 
-//` So now we can demonstrate with some trivial calculations:
+/*` So now we can demonstrate with some trivial calculations:
+*/
+
+//] //[big_seventh_example_1]
 
 int main()
 {
-/*`Using `typedef cpp_dec_float_50` hides the complexity of multiprecision to allow us
-  to define variables with 50 decimal digit precision just like built-in `double`.
+
+//[big_seventh_example_2
+/*`Using `typedef cpp_dec_float_50` hides the complexity of multiprecision,
+allows us  to define variables with 50 decimal digit precision just like built-in `double`.
 */
   using boost::multiprecision::cpp_dec_float_50;
 
-  cpp_dec_float_50 seventh = cpp_dec_float_50(1) / 7;
+  cpp_dec_float_50 seventh = cpp_dec_float_50(1) / 7;  // 1 / 7
 
-  /*`By default, output would only show the standard 6 decimal digits,
    so set precision to show all 50 significant digits.
-  */
+/*`By default, output would only show the standard 6 decimal digits,
so set precision to show all 50 significant digits, including any trailing zeros.
+*/
   std::cout.precision(std::numeric_limits<cpp_dec_float_50>::digits10);
+  std::cout << std::showpoint << std::endl; // Append any trailing zeros.
   std::cout << seventh << std::endl;
 /*`which outputs:
 
   0.14285714285714285714285714285714285714285714285714
 
-We can also use constants, guaranteed to be initialized with the very last bit of precision.
+We can also use Boost.Math __constants like [pi],
+guaranteed to be initialized with the very last bit of precision for the floating-point type.
 */
 
-  cpp_dec_float_50 circumference = boost::math::constants::pi<cpp_dec_float_50>() * 2 * seventh;
-
-  std::cout << circumference << std::endl;
+   std::cout << "pi = " << boost::math::constants::pi<cpp_dec_float_50>() << std::endl;
+   cpp_dec_float_50 circumference = boost::math::constants::pi<cpp_dec_float_50>() * 2 * seventh;
+   std::cout << "c =  "<< circumference << std::endl;
 
 /*`which outputs
 
-    0.89759790102565521098932668093700082405633411410717
+  pi = 3.1415926535897932384626433832795028841971693993751
+
+  c =  0.89759790102565521098932668093700082405633411410717
 */
-//]  [/big_seventh_example_1]
+//]  [/big_seventh_example_2]
 
     return 0;
 } // int main()
@@ -80,10 +88,11 @@ We can also use constants, guaranteed to be initialized with the very last bit o
 /*
 //[big_seventh_example_output
 
-  0.14285714285714285714285714285714285714285714285714
-  0.89759790102565521098932668093700082405633411410717
+0.14285714285714285714285714285714285714285714285714
+pi = 3.1415926535897932384626433832795028841971693993751
+c =  0.89759790102565521098932668093700082405633411410717
 
-//]
+//] //[big_seventh_example_output]
 
 */