$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r73598 - in sandbox/e_float: boost/e_float libs/e_float/src/e_float/gmp
From: e_float_at_[hidden]
Date: 2011-08-07 12:16:23
Author: christopher_kormanyos
Date: 2011-08-07 12:16:20 EDT (Sun, 07 Aug 2011)
New Revision: 73598
URL: http://svn.boost.org/trac/boost/changeset/73598
Log:
- Cleanup. Testing and verification of all three back-ends.
Text files modified: 
   sandbox/e_float/boost/e_float/e_float_efx.hpp                     |     7 +--                                     
   sandbox/e_float/boost/e_float/e_float_gmp.hpp                     |    11 ++---                                   
   sandbox/e_float/boost/e_float/e_float_mpfr.hpp                    |    10 ++++-                                   
   sandbox/e_float/boost/e_float/e_float_types.hpp                   |     9 ----                                    
   sandbox/e_float/libs/e_float/src/e_float/gmp/e_float_gmp.cpp      |    79 +++++---------------------------------- 
   sandbox/e_float/libs/e_float/src/e_float/gmp/e_float_gmp_protos.h |     2                                         
   6 files changed, 27 insertions(+), 91 deletions(-)
Modified: sandbox/e_float/boost/e_float/e_float_efx.hpp
==============================================================================
--- sandbox/e_float/boost/e_float/e_float_efx.hpp	(original)
+++ sandbox/e_float/boost/e_float/e_float_efx.hpp	2011-08-07 12:16:20 EDT (Sun, 07 Aug 2011)
@@ -57,7 +57,6 @@
       INT32      prec_elem;
 
     public:
-
       // Constructors
       e_float() : data     (),
                   exp      (static_cast<INT64>(0)),
@@ -97,6 +96,7 @@
     public:
       virtual INT32 cmp(const e_float& v) const;
 
+      // Specific special values.
       virtual const e_float& my_value_nan(void) const;
       virtual const e_float& my_value_inf(void) const;
       virtual const e_float& my_value_max(void) const;
@@ -115,8 +115,10 @@
       virtual e_float& mul_unsigned_long_long(const unsigned long long n);
       virtual e_float& div_unsigned_long_long(const unsigned long long n);
 
+      // Elementary primitives.
       virtual e_float& calculate_inv (void);
       virtual e_float& calculate_sqrt(void);
+      virtual e_float& negate(void) { if(!iszero()) { neg = !neg; } return *this; }
 
       // Comparison functions
       virtual bool isnan   (void) const { return (fpclass == ef_NaN); }
@@ -128,8 +130,6 @@
       virtual bool isint  (void) const;
       virtual bool isneg  (void) const { return neg; }
 
-      virtual e_float& negate(void) { if(!iszero()) { neg = !neg; } return *this; }
-
       // Operators pre-increment and pre-decrement
       virtual e_float& operator++(void);
       virtual e_float& operator--(void);
@@ -160,7 +160,6 @@
       virtual void get_output_string(std::string& str, INT64& my_exp, const std::size_t number_of_digits) const;
 
       virtual bool rd_string(const char* const s);
-
     };
   }
 
Modified: sandbox/e_float/boost/e_float/e_float_gmp.hpp
==============================================================================
--- sandbox/e_float/boost/e_float/e_float_gmp.hpp	(original)
+++ sandbox/e_float/boost/e_float/e_float_gmp.hpp	2011-08-07 12:16:20 EDT (Sun, 07 Aug 2011)
@@ -57,9 +57,8 @@
     class e_float : public ::e_float_base
     {
     public:
-
       static const INT32 ef_digits    = static_cast<INT32>(((static_cast<INT64>(ef_digits10) * 3322LL) + 500LL) / 1000LL);
-      static const INT32 ef_radix     = 2;
+      static const INT32 ef_radix     = static_cast<INT32>(2);
 
       static const INT64 ef_max_exp   = static_cast<INT64>(+2147483640LL);
       static const INT64 ef_min_exp   = static_cast<INT64>(-2147483640LL);
@@ -67,7 +66,6 @@
       static const INT64 ef_min_exp10 = static_cast<INT64>(-646456990LL);
 
     private:
-
       static const INT32 ef_digits2 = static_cast<INT32>(((static_cast<INT64>(ef_digits10_tol) * 3322LL) + 500LL) / 1000LL);
 
       typedef enum enum_fpclass
@@ -83,6 +81,7 @@
       ::mpf_t   rop;
 
     public:
+      // Constructors
       e_float();
       e_float(const char n);
       e_float(const signed char n);
@@ -111,9 +110,9 @@
       explicit e_float(const ::mpf_t& op);
 
     public:
-
       virtual INT32 cmp(const e_float& v) const;
 
+      // Specific special values.
       virtual const e_float& my_value_nan(void) const;
       virtual const e_float& my_value_inf(void) const;
       virtual const e_float& my_value_max(void) const;
@@ -132,8 +131,10 @@
       virtual e_float& mul_unsigned_long_long(const unsigned long long n);
       virtual e_float& div_unsigned_long_long(const unsigned long long n);
 
+      // Elementary primitives.
       virtual e_float& calculate_inv (void);
       virtual e_float& calculate_sqrt(void);
+      virtual e_float& negate(void);
 
       // Comparison functions
       virtual bool isnan   (void) const { return (fpclass == ef_NaN); }
@@ -145,8 +146,6 @@
       virtual bool isint  (void) const;
       virtual bool isneg  (void) const;
 
-      virtual e_float& negate(void);
-
       // Operators pre-increment and pre-decrement
       virtual e_float& operator++(void);
       virtual e_float& operator--(void);
Modified: sandbox/e_float/boost/e_float/e_float_mpfr.hpp
==============================================================================
--- sandbox/e_float/boost/e_float/e_float_mpfr.hpp	(original)
+++ sandbox/e_float/boost/e_float/e_float_mpfr.hpp	2011-08-07 12:16:20 EDT (Sun, 07 Aug 2011)
@@ -78,6 +78,7 @@
       ::mpfr_t rop;
 
     public:
+      // Constructors
       e_float();
       e_float(const char n);
       e_float(const signed char n);
@@ -104,6 +105,7 @@
 
       virtual INT32 cmp(const e_float& v) const;
 
+      // Specific special values.
       virtual const e_float& my_value_nan(void) const;
       virtual const e_float& my_value_inf(void) const;
       virtual const e_float& my_value_max(void) const;
@@ -111,6 +113,7 @@
 
       virtual void precision(const INT32) { }
 
+      // Basic operations.
       virtual e_float& operator= (const e_float& v);
       virtual e_float& operator+=(const e_float& v);
       virtual e_float& operator-=(const e_float& v);
@@ -121,9 +124,12 @@
       virtual e_float& mul_unsigned_long_long(const unsigned long long n);
       virtual e_float& div_unsigned_long_long(const unsigned long long n);
 
+      // Elementary primitives.
       virtual e_float& calculate_inv (void);
       virtual e_float& calculate_sqrt(void);
+      virtual e_float& negate(void);
 
+      // Comparison functions
       virtual bool isnan   (void) const;
       virtual bool isinf   (void) const;
       virtual bool isfinite(void) const;
@@ -133,11 +139,11 @@
       virtual bool isint   (void) const;
       virtual bool isneg   (void) const;
 
-      virtual e_float& negate(void);
-
+      // Operators pre-increment and pre-decrement.
       virtual e_float& operator++(void);
       virtual e_float& operator--(void);
 
+      // Conversion routines.
       virtual void               extract_parts             (double& mantissa, INT64& exponent) const;
       virtual double             extract_double            (void) const;
       virtual long double        extract_long_double       (void) const;
Modified: sandbox/e_float/boost/e_float/e_float_types.hpp
==============================================================================
--- sandbox/e_float/boost/e_float/e_float_types.hpp	(original)
+++ sandbox/e_float/boost/e_float/e_float_types.hpp	2011-08-07 12:16:20 EDT (Sun, 07 Aug 2011)
@@ -29,14 +29,5 @@
 
   typedef   signed int    INT32;
   typedef unsigned int   UINT32;
-  typedef   signed short  INT16;
-  typedef unsigned short UINT16;
-
-  #ifndef _WINDEF_
-
-    typedef signed char    INT8;
-    typedef unsigned char UINT8;
-
-  #endif
 
 #endif // _E_FLOAT_TYPES_HPP_
Modified: sandbox/e_float/libs/e_float/src/e_float/gmp/e_float_gmp.cpp
==============================================================================
--- sandbox/e_float/libs/e_float/src/e_float/gmp/e_float_gmp.cpp	(original)
+++ sandbox/e_float/libs/e_float/src/e_float/gmp/e_float_gmp.cpp	2011-08-07 12:16:20 EDT (Sun, 07 Aug 2011)
@@ -866,18 +866,17 @@
     return ((!b_neg) ? static_cast<signed long long>(1) : static_cast<signed long long>(-1));
   }
 
+  // Extract a signed long long-type string from e_float.
   static const char c0 = static_cast<char>('\0');
-
   std::vector<char> str(64u, c0);
-
   mp_exp_t p10;
 
   static_cast<void>(::mpf_get_str(&str[0], &p10, 10, str.size() - 1u, nx.rop));
 
   std::string str_sll(static_cast<std::size_t>(p10), static_cast<char>('0'));
-
   std::copy(str.begin(), std::find(str.begin(), str.end(), c0), str_sll.begin());
 
+  // Get the signed long long result.
   std::stringstream ss;
   ss << str_sll;
   signed long long n;
@@ -918,20 +917,19 @@
     return static_cast<unsigned long long>(1u);
   }
 
+  // Extract an unsigned long long-type string from e_float.
   static const char c0 = static_cast<char>('\0');
-
   std::vector<char> str(64u, c0);
-
   mp_exp_t p10;
 
   static_cast<void>(::mpf_get_str(&str[0], &p10, 10, str.size() - 1u, nx.rop));
 
-  std::string str_sll(static_cast<std::size_t>(p10), static_cast<char>('0'));
-
-  std::copy(str.begin(), std::find(str.begin(), str.end(), c0), str_sll.begin());
+  std::string str_ull(static_cast<std::size_t>(p10), static_cast<char>('0'));
+  std::copy(str.begin(), std::find(str.begin(), str.end(), c0), str_ull.begin());
 
+  // Get the unsigned long long result.
   std::stringstream ss;
-  ss << str_sll;
+  ss << str_ull;
   unsigned long long n;
   ss >> n;
 
@@ -970,7 +968,7 @@
   std::string str_fmt = std::string("%.10Fe");
 
   // Get the ten digits.
-  std::tr1::array<char, 64u> buf = {{ static_cast<char>(0) }};
+  std::tr1::array<char, 64u> buf = {{ static_cast<char>('0') }};
 
   static_cast<void>(gmp_sprintf(buf.data(), str_fmt.c_str(), rop));
 
@@ -1014,60 +1012,6 @@
   }
 }
 
-/*
-void gmp::e_float::wr_string(std::string& str, std::ostream& os) const
-{
-  if(isnan())
-  {
-    str = "NaN";
-    return;
-  }
-
-  if(isinf())
-  {
-    str = "INF";
-    return;
-  }
-
-  static const std::streamsize p_min = static_cast<std::streamsize>(10);
-  static const std::streamsize p_lim = static_cast<std::streamsize>(ef_digits10_tol);
-         const std::streamsize p     = (std::max)(os.precision(), p_min);
-
-  const std::streamsize my_precision = (std::min)(p, p_lim);
-
-  const std::ios::fmtflags f = os.flags();
-
-  const bool my_uppercase  = ((f & std::ios::uppercase)  != static_cast<std::ios::fmtflags>(0u));
-  const bool my_showpos    = ((f & std::ios::showpos)    != static_cast<std::ios::fmtflags>(0u));
-  const bool my_scientific = ((f & std::ios::scientific) != static_cast<std::ios::fmtflags>(0u));
-
-  // Create a format string such as "%+.99Fe"
-  const std::string str_fmt =   (my_showpos ? "%+." : "%.")
-                              + Util::lexical_cast(my_precision - (my_scientific ? 1 : 0))
-                              + (my_scientific ? (my_uppercase ? "FE" : "Fe") : (my_uppercase ? "FG" : "Fg"));
-
-  std::tr1::array<char, static_cast<std::size_t>(e_float::ef_digits10_tol + 32)> buf = {{ static_cast<char>(0) }};
-
-  static_cast<void>(gmp_sprintf(buf.data(), str_fmt.c_str(), rop));
-
-  // Set the result string and remove the '\0' padding by using the c_str() representation.
-  str = std::string(buf.data());
-
-  const std::size_t pos_E = (my_uppercase ? str.rfind('E') : str.rfind('e'));
-
-  if(pos_E != std::string::npos)
-  {
-    // Pad the exponent number field with additional zeros such that the width
-    // of the exponent number field is equal to the width of ef_max_exp10.
-    const std::size_t pos_exp = static_cast<std::string::size_type>(pos_E + 2u);
-
-    const std::string::size_type width_of_exp = str.length() - pos_exp;
-
-    str.insert(pos_exp, std::string(width_of_exponent_field() - width_of_exp, static_cast<char>('0')));
-  }
-}
-*/
-
 void gmp::e_float::get_output_string(std::string& str, INT64& my_exp, const std::size_t number_of_digits) const
 {
   static_cast<void>(my_exp);
@@ -1079,7 +1023,7 @@
   const std::string str_fmt = std::string("%.") + (Util::lexical_cast(the_number_of_digits_scientific) + "Fe");
 
   // Get the string representation of the e_float in scientific notation (lowercase, noshowpos).
-  std::tr1::array<char, static_cast<std::size_t>(e_float::ef_digits10_tol + 32)> buf = {{ static_cast<char>(0) }};
+  std::tr1::array<char, static_cast<std::size_t>(e_float::ef_digits10_tol + 32)> buf = {{ static_cast<char>('0') }};
 
   static_cast<void>(gmp_sprintf(buf.data(), str_fmt.c_str(), rop));
 
@@ -1185,10 +1129,7 @@
   // Set the e_float value.
   const INT32 n_set_result = static_cast<INT32>(::mpf_init_set_str(rop, str.c_str(), 10));
 
-  if(b_negate)
-  {
-    negate();
-  }
+  if(b_negate) { negate(); }
 
   return (n_set_result == static_cast<INT32>(0));
 }
Modified: sandbox/e_float/libs/e_float/src/e_float/gmp/e_float_gmp_protos.h
==============================================================================
--- sandbox/e_float/libs/e_float/src/e_float/gmp/e_float_gmp_protos.h	(original)
+++ sandbox/e_float/libs/e_float/src/e_float/gmp/e_float_gmp_protos.h	2011-08-07 12:16:20 EDT (Sun, 07 Aug 2011)
@@ -63,7 +63,7 @@
   inline void   mpf_floor           (mpf_ptr dst, mpf_srcptr x)                             {        ::__gmpf_floor              (dst, x); }
   inline void   mpf_sqrt            (mpf_ptr dst, mpf_srcptr x)                             {        ::__gmpf_sqrt               (dst, x); }
   inline int    mpf_cmp             (mpf_srcptr x, mpf_srcptr y)                            { return ::__gmpf_cmp                (x, y); }
-  inline int    mpf_sgn             (mpf_srcptr x)                                          { return x->_mp_size < 0 ? -1 : (x->_mp_size > 0); }
+  inline int    mpf_sgn             (mpf_srcptr x)                                          { return ((x->_mp_size < 0) ? -1 : ((x->_mp_size > 0) ? 1 : 0)); }
   inline int    mpf_integer_p       (mpf_srcptr src)                                        { return ::__gmpf_integer_p          (src); }
   inline double mpf_get_d           (mpf_srcptr x)                                          { return ::__gmpf_get_d              (x); }
   inline double mpf_get_d_2exp      (signed long int* e, mpf_srcptr x)                      { return ::__gmpf_get_d_2exp         (e, x); }