1 /* Checked_Number class implementation.
2 Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3 Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4
5 This file is part of the Parma Polyhedra Library (PPL).
6
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23
24 #include "ppl-config.h"
25 #include "Checked_Number_defs.hh"
26
27 namespace Parma_Polyhedra_Library {
28
29 void
throw_result_exception(Result r)30 throw_result_exception(Result r) {
31 switch (r - V_UNREPRESENTABLE) {
32 case V_EMPTY:
33 throw std::domain_error("Exact result is not comparable to computable one.");
34 case V_EQ:
35 throw std::logic_error("Exact result is equal to computed one.");
36 case V_LT:
37 throw std::logic_error("Exact result is less than computed one.");
38 case V_LE:
39 throw std::logic_error("Exact result is less than or equal to "
40 "computed one.");
41 case V_GT:
42 throw std::logic_error("Exact result is greater than computed one.");
43 case V_GE:
44 throw std::logic_error("Exact result is greater than or equal to "
45 "computed one.");
46 case V_NE:
47 throw std::logic_error("Exact result is less than or greater than "
48 "computed one.");
49 case V_LGE:
50 throw std::logic_error("Exact result is less than, greater than or "
51 "equal to computed one.");
52 case V_EQ_MINUS_INFINITY:
53 throw std::overflow_error("Minus infinity.");
54 case V_GT_MINUS_INFINITY:
55 case V_LT_INF:
56 throw std::overflow_error("Negative overflow.");
57 case V_UNKNOWN_NEG_OVERFLOW:
58 throw std::overflow_error("Unknown result due to intermediate negative overflow.");
59 case V_EQ_PLUS_INFINITY:
60 throw std::overflow_error("Plus infinity.");
61 case V_LT_PLUS_INFINITY:
62 case V_GT_SUP:
63 throw std::overflow_error("Positive overflow.");
64 case V_UNKNOWN_POS_OVERFLOW:
65 throw std::overflow_error("Unknown result due to intermediate positive overflow.");
66 case V_NAN:
67 throw std::domain_error("Not-a-Number.");
68 case V_CVT_STR_UNK:
69 throw std::domain_error("Invalid numeric string.");
70 case V_DIV_ZERO:
71 throw std::domain_error("Division by zero.");
72 case V_INF_ADD_INF:
73 throw std::domain_error("Infinities addition.");
74 case V_INF_DIV_INF:
75 throw std::domain_error("Infinities division.");
76 case V_INF_MOD:
77 throw std::domain_error("Remainder of division of infinity.");
78 case V_INF_MUL_ZERO:
79 throw std::domain_error("Multiplication of infinity and zero.");
80 case V_INF_SUB_INF:
81 throw std::domain_error("Subtraction of infinities.");
82 case V_MOD_ZERO:
83 throw std::domain_error("Remainder of division by zero.");
84 case V_SQRT_NEG:
85 throw std::domain_error("Square root of negative number.");
86 default:
87 throw std::logic_error("Unexpected result.");
88 }
89 }
90
91 } // namespace Parma_Polyhedra_Library
92
93