[PPL-devel] [GIT] ppl/ppl(master): Fixed assignment to int.

Abramo Bagnara abramo.bagnara at gmail.com
Sun May 3 10:32:29 CEST 2009


Module: ppl/ppl
Branch: master
Commit: 7d02c66706d0ae61f3334658327806ddf44be05a
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=7d02c66706d0ae61f3334658327806ddf44be05a

Author: Abramo Bagnara <abramo.bagnara at gmail.com>
Date:   Sun May  3 10:28:04 2009 +0200

Fixed assignment to int.

---

 src/checked.cc             |    4 ++++
 src/checked.defs.hh        |    7 +++----
 src/checked_int.inlines.hh |   10 +++++-----
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/checked.cc b/src/checked.cc
index e21c25d..3529e87 100644
--- a/src/checked.cc
+++ b/src/checked.cc
@@ -26,6 +26,10 @@ site: http://www.cs.unipr.it/ppl/ . */
 
 namespace Parma_Polyhedra_Library {
 
+Minus_Infinity MINUS_INFINITY;
+Plus_Infinity PLUS_INFINITY;
+Not_A_Number NOT_A_NUMBER;
+
 namespace Checked {
 
 //! Holds the precision parameter used for rational sqrt calculations.
diff --git a/src/checked.defs.hh b/src/checked.defs.hh
index a1e76a9..207cb41 100644
--- a/src/checked.defs.hh
+++ b/src/checked.defs.hh
@@ -534,10 +534,9 @@ struct Is_Special<Plus_Infinity> : public True {};
 template <>
 struct Is_Special<Not_A_Number> : public True {};
 
-
-#define MINUS_INFINITY Minus_Infinity()
-#define PLUS_INFINITY Plus_Infinity()
-#define NOT_A_NUMBER Not_A_Number()
+extern Minus_Infinity MINUS_INFINITY;
+extern Plus_Infinity PLUS_INFINITY;
+extern Not_A_Number NOT_A_NUMBER;
 
 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
 /*! \ingroup PPL_CXX_interface */
diff --git a/src/checked_int.inlines.hh b/src/checked_int.inlines.hh
index 3c20853..d3a5d68 100644
--- a/src/checked_int.inlines.hh
+++ b/src/checked_int.inlines.hh
@@ -561,9 +561,9 @@ assign_signed_int_mpz(To& to, const mpz_class& from, Rounding_Dir dir) {
     }
     if (from.fits_slong_p()) {
       signed long v = from.get_si();
-      if (v < C_Integer<To>::min)
+      if (v < Extended_Int<To_Policy, To>::min)
 	return set_neg_overflow_int<To_Policy>(to, dir);
-      if (v > C_Integer<To>::max)
+      if (v > Extended_Int<To_Policy, To>::max)
 	return set_pos_overflow_int<To_Policy>(to, dir);
       to = v;
       return V_EQ;
@@ -610,7 +610,7 @@ assign_unsigned_int_mpz(To& to, const mpz_class& from, Rounding_Dir dir) {
     }
     if (from.fits_ulong_p()) {
       unsigned long v = from.get_ui();
-      if (v > C_Integer<To>::max)
+      if (v > Extended_Int<To_Policy, To>::max)
 	return set_pos_overflow_int<To_Policy>(to, dir);
       to = v;
       return V_EQ;
@@ -1109,7 +1109,7 @@ template <typename To_Policy, typename From_Policy, typename Type>
 inline Result
 div_2exp_signed_int(Type& to, const Type x, unsigned int exp,
                     Rounding_Dir dir) {
-  if (exp >= sizeof(Type) * 8) {
+  if (exp > sizeof(Type) * 8 - 1) {
   zero:
     to = 0;
     if (round_ignore(dir))
@@ -1121,7 +1121,7 @@ div_2exp_signed_int(Type& to, const Type x, unsigned int exp,
     else
       return V_EQ;
   }
-  if (exp >= sizeof(Type) * 8 - 1) {
+  if (exp == sizeof(Type) * 8 - 1) {
     if (x == C_Integer<Type>::min) {
       to = -1;
       return V_EQ;




More information about the PPL-devel mailing list