[PPL-devel] [GIT] ppl/ppl(bounded_arithmetic): Added missing Result values.

Abramo Bagnara abramo.bagnara at gmail.com
Thu May 14 08:46:01 CEST 2009


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

Author: Abramo Bagnara <abramo.bagnara at gmail.com>
Date:   Thu May 14 08:45:36 2009 +0200

Added missing Result values.

---

 src/Checked_Number.cc         |   14 +++++++++++---
 src/Checked_Number.inlines.hh |    2 +-
 src/Result.defs.hh            |    8 ++++----
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/Checked_Number.cc b/src/Checked_Number.cc
index 03ec838..5852e6a 100644
--- a/src/Checked_Number.cc
+++ b/src/Checked_Number.cc
@@ -27,7 +27,11 @@ namespace Parma_Polyhedra_Library {
 
 void
 throw_result_exception(Result r) {
-  switch (r) {
+  switch (r - V_UNREPRESENTABLE) {
+  case V_EMPTY:
+    throw std::domain_error("Exact result is not comparable to computable one.");
+  case V_EQ:
+    throw std::logic_error("Exact result is equal to computed one.");
   case V_LT:
     throw std::logic_error("Exact result is less than computed one.");
   case V_LE:
@@ -47,15 +51,19 @@ throw_result_exception(Result r) {
   case V_EQ_MINUS_INFINITY:
     throw std::overflow_error("Minus infinity.");
   case V_GT_MINUS_INFINITY:
+  case V_LT_INF:
     throw std::overflow_error("Negative overflow.");
   case V_UNKNOWN_NEG_OVERFLOW:
-    throw std::overflow_error("Unknown result due to negative overflow.");
+    throw std::overflow_error("Unknown result due to intermediate negative overflow.");
   case V_EQ_PLUS_INFINITY:
     throw std::overflow_error("Plus infinity.");
   case V_LT_PLUS_INFINITY:
+  case V_GT_SUP:
     throw std::overflow_error("Positive overflow.");
   case V_UNKNOWN_POS_OVERFLOW:
-    throw std::overflow_error("Unknown result due to positive overflow.");
+    throw std::overflow_error("Unknown result due to intermediate positive overflow.");
+  case V_NAN:
+    throw std::domain_error("Not-a-Number.");
   case V_CVT_STR_UNK:
     throw std::domain_error("Invalid numeric string.");
   case V_DIV_ZERO:
diff --git a/src/Checked_Number.inlines.hh b/src/Checked_Number.inlines.hh
index 5996143..20babf4 100644
--- a/src/Checked_Number.inlines.hh
+++ b/src/Checked_Number.inlines.hh
@@ -33,7 +33,7 @@ inline Rounding_Dir
 rounding_dir(Rounding_Dir dir) {
   if (dir == ROUND_NOT_NEEDED) {
 #ifdef DEBUG_ROUND_NOT_NEEDED
-    return ROUND_DIRECT & ROUND_FPU_CHECK_INEXACT;
+    return ROUND_CHECK;
 #else
     return ROUND_IGNORE;
 #endif
diff --git a/src/Result.defs.hh b/src/Result.defs.hh
index 613ddb4..ae68372 100644
--- a/src/Result.defs.hh
+++ b/src/Result.defs.hh
@@ -100,9 +100,6 @@ enum Result {
   //! \hideinitializer The exact result is a number out of finite bounds.
   V_OVERFLOW = 1 << 6,
 
-  //! \hideinitializer The computed result is not representable.
-  V_UNREPRESENTABLE = 1 << 7,
-
   //! \hideinitializer A negative integer overflow occurred (rounding up).
   V_LT_INF = V_LT | V_OVERFLOW,
 
@@ -155,7 +152,10 @@ enum Result {
   V_UNKNOWN_NEG_OVERFLOW = V_NAN | (10 << 8),
 
   //! \hideinitializer Unknown result due to intermediate positive overflow.
-  V_UNKNOWN_POS_OVERFLOW = V_NAN | (11 << 8)
+  V_UNKNOWN_POS_OVERFLOW = V_NAN | (11 << 8),
+
+  //! \hideinitializer The computed result is not representable.
+  V_UNREPRESENTABLE = 1 << 7,
 
 };
 




More information about the PPL-devel mailing list