Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71438 - trunk/libs/math/example
From: pbristow_at_[hidden]
Date: 2011-04-23 09:51:29


Author: pbristow
Date: 2011-04-23 09:51:28 EDT (Sat, 23 Apr 2011)
New Revision: 71438
URL: http://svn.boost.org/trac/boost/changeset/71438

Log:
Added check that infinity supported. and ends with newline.
Text files modified:
   trunk/libs/math/example/nonfinite_facet_simple.cpp | 21 +++++++++++++++++++--
   1 files changed, 19 insertions(+), 2 deletions(-)

Modified: trunk/libs/math/example/nonfinite_facet_simple.cpp
==============================================================================
--- trunk/libs/math/example/nonfinite_facet_simple.cpp (original)
+++ trunk/libs/math/example/nonfinite_facet_simple.cpp 2011-04-23 09:51:28 EDT (Sat, 23 Apr 2011)
@@ -19,7 +19,8 @@
 \brief A very simple example of using non_finite_num facet for
 C99 standard output of infinity and NaN.
 
-\detail This example shows how to create a C99 non-finite locale,
+\detail Provided infinity and nan are supported,
+this example shows how to create a C99 non-finite locale,
 and imbue input and output streams with the non_finite_num put and get facets.
 This allow output and input of infinity and NaN in a Standard portable way,
 This permits 'loop-back' of output back into input (and portably across different system too).
@@ -28,6 +29,10 @@
 
 */
 
+#ifdef _MSC_VER
+# pragma warning (disable : 4127) // conditional expression is constant.
+#endif
+
 #include <iostream>
 using std::cout;
 using std::endl;
@@ -58,6 +63,18 @@
 {
   std::cout << "Nonfinite_num_facet very simple example." << std::endl;
 
+ if((std::numeric_limits<double>::has_infinity == 0) || (std::numeric_limits<double>::infinity() == 0))
+ {
+ std::cout << "Infinity not supported on this platform." << std::endl;
+ return 0;
+ }
+
+ if((std::numeric_limits<double>::has_quiet_NaN == 0) || (std::numeric_limits<double>::quiet_NaN() == 0))
+ {
+ std::cout << "NaN not supported on this platform." << std::endl;
+ return 0;
+ }
+
   std::locale default_locale (std::locale::classic ()); // Note the currrent (default C) locale.
 
   // Create plus and minus infinity.
@@ -239,4 +256,4 @@
   infinity in C99 representation (setw(20) is inf |
   infinity in C99 representation (setw(20) is inf|
 
-*/
\ No newline at end of file
+*/


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