p1788 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +8 -0
  3. data/AUTHORS +6 -0
  4. data/LICENSE +201 -0
  5. data/NOTICE +29 -0
  6. data/README.md +65 -0
  7. data/ext/libieeep1788_copy/README +3 -0
  8. data/ext/libieeep1788_copy/p1788/AUTHORS +16 -0
  9. data/ext/libieeep1788_copy/p1788/LICENSE +202 -0
  10. data/ext/libieeep1788_copy/p1788/NOTICE +14 -0
  11. data/ext/libieeep1788_copy/p1788/decoration/decoration.hpp +265 -0
  12. data/ext/libieeep1788_copy/p1788/exception/exception.hpp +302 -0
  13. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor.hpp +3443 -0
  14. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_bool_func_impl.hpp +608 -0
  15. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_cancel_func_impl.hpp +229 -0
  16. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_class_impl.hpp +526 -0
  17. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_elem_func_impl.hpp +4533 -0
  18. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_io_impl.hpp +1421 -0
  19. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_mul_rev_to_pair_func_impl.hpp +347 -0
  20. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_num_func_impl.hpp +655 -0
  21. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_rec_bool_func_impl.hpp +146 -0
  22. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_rec_overlap_impl.hpp +188 -0
  23. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_rev_func_impl.hpp +1674 -0
  24. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_set_op_impl.hpp +216 -0
  25. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_setup_func_impl.hpp +68 -0
  26. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_util_func_impl.hpp +135 -0
  27. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_validation_func_impl.hpp +93 -0
  28. data/ext/libieeep1788_copy/p1788/infsup/base_interval.hpp +1529 -0
  29. data/ext/libieeep1788_copy/p1788/infsup/base_interval_bool_func_impl.hpp +481 -0
  30. data/ext/libieeep1788_copy/p1788/infsup/base_interval_cancel_func_impl.hpp +126 -0
  31. data/ext/libieeep1788_copy/p1788/infsup/base_interval_elem_func_impl.hpp +1581 -0
  32. data/ext/libieeep1788_copy/p1788/infsup/base_interval_io_impl.hpp +59 -0
  33. data/ext/libieeep1788_copy/p1788/infsup/base_interval_mul_rev_to_pair_func_impl.hpp +88 -0
  34. data/ext/libieeep1788_copy/p1788/infsup/base_interval_num_func_impl.hpp +345 -0
  35. data/ext/libieeep1788_copy/p1788/infsup/base_interval_rec_bool_func_impl.hpp +92 -0
  36. data/ext/libieeep1788_copy/p1788/infsup/base_interval_rec_overlap_impl.hpp +72 -0
  37. data/ext/libieeep1788_copy/p1788/infsup/base_interval_rev_func_impl.hpp +656 -0
  38. data/ext/libieeep1788_copy/p1788/infsup/base_interval_set_op_impl.hpp +126 -0
  39. data/ext/libieeep1788_copy/p1788/infsup/decorated_interval.hpp +464 -0
  40. data/ext/libieeep1788_copy/p1788/infsup/forward_declaration.hpp +66 -0
  41. data/ext/libieeep1788_copy/p1788/infsup/interval.hpp +275 -0
  42. data/ext/libieeep1788_copy/p1788/io/io_manip.hpp +531 -0
  43. data/ext/libieeep1788_copy/p1788/overlapping/overlapping.hpp +241 -0
  44. data/ext/libieeep1788_copy/p1788/p1788.hpp +45 -0
  45. data/ext/libieeep1788_copy/p1788/reduction/reduction.hpp +341 -0
  46. data/ext/libieeep1788_copy/p1788/util/io.hpp +63 -0
  47. data/ext/libieeep1788_copy/p1788/util/mixed_type_traits.hpp +140 -0
  48. data/ext/libieeep1788_copy/p1788/util/mpfr_util.hpp +77 -0
  49. data/ext/libieeep1788_copy/p1788/util/mpfr_var.hpp +119 -0
  50. data/ext/libieeep1788_copy/p1788/util/mpfr_var_impl.hpp +382 -0
  51. data/ext/libieeep1788_copy/p1788/version.hpp +34 -0
  52. data/ext/p1788/extconf.rb +49 -0
  53. data/ext/p1788/p1788.cc +3764 -0
  54. data/lib/p1788/version.rb +4 -0
  55. data/lib/p1788.rb +25 -0
  56. data/p1788.gemspec +72 -0
  57. metadata +99 -0
@@ -0,0 +1,265 @@
1
+ //
2
+ // libieeep1788
3
+ //
4
+ // An implementation of the preliminary IEEE P1788 standard for
5
+ // interval arithmetic
6
+ //
7
+ //
8
+ // Copyright 2013 - 2015
9
+ //
10
+ // Marco Nehmeier (nehmeier@informatik.uni-wuerzburg.de)
11
+ // Department of Computer Science,
12
+ // University of Wuerzburg, Germany
13
+ //
14
+ // Licensed under the Apache License, Version 2.0 (the "License");
15
+ // you may not use this file except in compliance with the License.
16
+ // You may obtain a copy of the License at
17
+ //
18
+ // http://www.apache.org/licenses/LICENSE-2.0
19
+ //
20
+ // Unless required by applicable law or agreed to in writing, software
21
+ // distributed under the License is distributed on an "AS IS" BASIS,
22
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
+ // See the License for the specific language governing permissions and
24
+ // limitations under the License.
25
+
26
+ #ifndef LIBIEEEP1788_P1788_DECORATION_DECORATION_HPP
27
+ #define LIBIEEEP1788_P1788_DECORATION_DECORATION_HPP
28
+
29
+ #include <iostream>
30
+ #include <algorithm>
31
+ #include <cstdint>
32
+
33
+ #include "p1788/io/io_manip.hpp"
34
+ #include "p1788/util/io.hpp"
35
+ #include "p1788/exception/exception.hpp"
36
+
37
+ namespace p1788
38
+ {
39
+
40
+ namespace decoration
41
+ {
42
+
43
+ /// \brief Enum describing the 5 different interval decorations
44
+ ///
45
+ /// The 5 different values are an ordered set with the following
46
+ /// property
47
+ ///
48
+ /// <c>com</c> > <c>dac</c> > <c>def</c> > <c>trv</c> > <c>ill</c>
49
+ ///
50
+ /// and the common comparison operators (<c>==</c>, <c>!=</c>, <c><</c>, <c><=</c>, <c>></c>, <c>>=</c>)
51
+ /// are supported.
52
+ ///
53
+ /// \note To follow the interchange representations specified by IEEE P1788
54
+ /// the decoration enum is based on an unsigned 8Bit integer using the
55
+ /// the corresponding Bit patterns for the particular values.
56
+ enum class decoration : uint8_t
57
+ {
58
+ ill = 0x00, ///< ill (00000000)
59
+ trv = 0x04, ///< trivial (00000100)
60
+ def = 0x08, ///< defined (00001000)
61
+ dac = 0x0C, ///< defined and continuous (00001100)
62
+ com = 0x10 ///< common (00010000)
63
+ };
64
+
65
+
66
+
67
+ bool is_valid(decoration dec)
68
+ {
69
+ switch(dec)
70
+ {
71
+ case decoration::ill:
72
+ case decoration::trv:
73
+ case decoration::def:
74
+ case decoration::dac:
75
+ case decoration::com:
76
+ return true;
77
+ }
78
+
79
+
80
+ // invalid: signal invalid operand
81
+ return !p1788::exception::signal_invalid_operand();
82
+ }
83
+
84
+
85
+
86
+ // -----------------------------------------------------------------------------
87
+ // Input and output
88
+ // -----------------------------------------------------------------------------
89
+
90
+
91
+ /// \brief Operator for writing a decoration onto an output stream.
92
+ ///
93
+ /// \param os Output stream
94
+ /// \param dec Decoration to write onto the output stream \p os
95
+ /// \return Output stream \p os to support operator chaining
96
+ ///
97
+ /// \note The function pays attention to the output manipulators
98
+ /// \link p1788::io::dec_alpha(std::basic_ostream<CharT, Traits>& os) dec_alpha \endlink ,
99
+ /// and \link p1788::io::dec_numeric(std::basic_ostream<CharT, Traits>& os) dec_numeric \endlink
100
+ /// as well as to
101
+ /// \link p1788::io::lower_case(std::basic_ostream<CharT, Traits>& os) lower_case \endlink
102
+ /// and \link p1788::io::upper_case(std::basic_ostream<CharT, Traits>& os) upper_case \endlink .
103
+ template<typename CharT, typename Traits>
104
+ std::basic_ostream<CharT, Traits>& operator<<(
105
+ std::basic_ostream<CharT, Traits>& os,
106
+ decoration dec)
107
+ {
108
+ // numeric
109
+ if (os.iword(p1788::io::dec_manip_id) == p1788::io::dec_numeric_representation)
110
+ {
111
+ return os << static_cast<unsigned int>(dec);
112
+ }
113
+
114
+ // alphabetic
115
+ switch (dec)
116
+ {
117
+ case decoration::ill:
118
+ switch (os.iword(p1788::io::text_representation_manip_id))
119
+ {
120
+ case p1788::io::upper_case_text_representation:
121
+ return os << "ILL";
122
+ default:
123
+ return os << "ill";
124
+ }
125
+ case decoration::trv:
126
+ switch (os.iword(p1788::io::text_representation_manip_id))
127
+ {
128
+ case p1788::io::upper_case_text_representation:
129
+ return os << "TRV";
130
+ default:
131
+ return os << "trv";
132
+ }
133
+ case decoration::def:
134
+ switch (os.iword(p1788::io::text_representation_manip_id))
135
+ {
136
+ case p1788::io::upper_case_text_representation:
137
+ return os << "DEF";
138
+ default:
139
+ return os << "def";
140
+ }
141
+ case decoration::dac:
142
+ switch (os.iword(p1788::io::text_representation_manip_id))
143
+ {
144
+ case p1788::io::upper_case_text_representation:
145
+ return os << "DAC";
146
+ default:
147
+ return os << "dac";
148
+ }
149
+ case decoration::com:
150
+ switch (os.iword(p1788::io::text_representation_manip_id))
151
+ {
152
+ case p1788::io::upper_case_text_representation:
153
+ return os << "COM";
154
+ default:
155
+ return os << "com";
156
+ }
157
+ }
158
+
159
+ // Something went wrong ;-)
160
+ return os;
161
+ }
162
+
163
+ /// \brief Operator for reading a decoration from an input stream.
164
+ ///
165
+ /// \param is Input stream
166
+ /// \param dec Decoration read from the input stream \p is
167
+ /// \return Input stream \p is to support operator chaining
168
+ ///
169
+ /// \note The function pays attention to the standard manipulator <c>std::ios_base::skipws</c>.
170
+ ///
171
+ /// \note If no valid textual or numeric representation could be read from the input stream \p is
172
+ /// then \p dec is set to decoration::ill and the <c>failbit</c>
173
+ /// of the stream is set.
174
+ template<typename CharT, typename Traits>
175
+ std::basic_istream<CharT, Traits>& operator>>(
176
+ std::basic_istream<CharT, Traits>& is,
177
+ decoration& dec )
178
+ {
179
+ // remove whitespaces if necessary
180
+ if (is.flags() & std::ios_base::skipws)
181
+ {
182
+ p1788::util::remove_ws(is);
183
+ }
184
+
185
+ if (is)
186
+ {
187
+ // starts with digit
188
+ if (std::isdigit(is.peek()))
189
+ {
190
+ unsigned int n;
191
+ is >> n;
192
+
193
+ if (is)
194
+ {
195
+ switch (n)
196
+ {
197
+ case 0x00: // ill
198
+ dec = decoration::ill;
199
+ return is;
200
+ case 0x04: // trv
201
+ dec = decoration::trv;
202
+ return is;
203
+ case 0x08: // def
204
+ dec = decoration::def;
205
+ return is;
206
+ case 0x0C: // dac
207
+ dec = decoration::dac;
208
+ return is;
209
+ case 0x10: // com
210
+ dec = decoration::com;
211
+ return is;
212
+ }
213
+ }
214
+ }
215
+ else // alphabetic
216
+ {
217
+ std::string s;
218
+ s.resize(3);
219
+ is.read(&s[0], 3);
220
+
221
+ if (is)
222
+ {
223
+ p1788::util::ascii_to_lower(s);
224
+
225
+ if (s == "ill")
226
+ {
227
+ dec = decoration::ill;
228
+ return is;
229
+ }
230
+ else if (s == "trv")
231
+ {
232
+ dec = decoration::trv;
233
+ return is;
234
+ }
235
+ else if (s == "def")
236
+ {
237
+ dec = decoration::def;
238
+ return is;
239
+ }
240
+ else if (s == "dac")
241
+ {
242
+ dec = decoration::dac;
243
+ return is;
244
+ }
245
+ else if (s == "com")
246
+ {
247
+ dec = decoration::com;
248
+ return is;
249
+ }
250
+ }
251
+ }
252
+ }
253
+
254
+ // failed
255
+ is.setstate(std::ios_base::failbit);
256
+ return is;
257
+ }
258
+
259
+
260
+ } // namespace decoration
261
+
262
+ } // namespace p1788
263
+
264
+
265
+ #endif // LIBIEEEP1788_P1788_DECORATION_DECORATION_HPP
@@ -0,0 +1,302 @@
1
+ //
2
+ // libieeep1788
3
+ //
4
+ // An implementation of the preliminary IEEE P1788 standard for
5
+ // interval arithmetic
6
+ //
7
+ //
8
+ // Copyright 2013 - 2015
9
+ //
10
+ // Marco Nehmeier (nehmeier@informatik.uni-wuerzburg.de)
11
+ // Department of Computer Science,
12
+ // University of Wuerzburg, Germany
13
+ //
14
+ // Licensed under the Apache License, Version 2.0 (the "License");
15
+ // you may not use this file except in compliance with the License.
16
+ // You may obtain a copy of the License at
17
+ //
18
+ // http://www.apache.org/licenses/LICENSE-2.0
19
+ //
20
+ // Unless required by applicable law or agreed to in writing, software
21
+ // distributed under the License is distributed on an "AS IS" BASIS,
22
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
+ // See the License for the specific language governing permissions and
24
+ // limitations under the License.
25
+
26
+ #ifndef LIBIEEEP1788_P1788_EXCEPTION_EXCEPTION_HPP
27
+ #define LIBIEEEP1788_P1788_EXCEPTION_EXCEPTION_HPP
28
+
29
+ #include <stdexcept>
30
+
31
+ namespace p1788
32
+ {
33
+
34
+ namespace exception
35
+ {
36
+
37
+ //TODO Exception Handler!
38
+
39
+
40
+ /// \brief Bit-patterns for the different kinds of exceptions
41
+ ///
42
+ /// \note The bitwise operators <c>&</c>, <c>|</c>, <c>^</c>, <c>~</c>,
43
+ /// <c>&=</c>, <c>|=</c>, <c>^=</c> are supported.
44
+ enum exception_bits
45
+ {
46
+ none_bit = 0, ///< No exception
47
+ undefined_operation_bit = 1, ///< No level 1 value exists
48
+ possibly_undefined_operation_bit = 2, ///< Not sure if a level 1 value exists
49
+ interval_part_of_nai_bit = 4, ///< A NaI is converted into a bare interval
50
+ invalid_operand_bit = 8 ///< Invalid input for an operation
51
+ };
52
+
53
+
54
+ // bitwise AND for exception_bits
55
+ inline exception_bits operator& (exception_bits x, exception_bits y)
56
+ {
57
+ return exception_bits(static_cast<int>(x) & static_cast<int>(y));
58
+ }
59
+
60
+ // bitwise OR for exception_bits
61
+ inline exception_bits operator| (exception_bits x, exception_bits y)
62
+ {
63
+ return exception_bits(static_cast<int>(x) | static_cast<int>(y));
64
+ }
65
+
66
+ // bitwise XOR for exception_bits
67
+ inline exception_bits operator^ (exception_bits x, exception_bits y)
68
+ {
69
+ return exception_bits(static_cast<int>(x) ^ static_cast<int>(y));
70
+ }
71
+
72
+ // bitwise NOT for exception_bits
73
+ inline exception_bits operator~ (exception_bits x)
74
+ {
75
+ return exception_bits(~static_cast<int>(x));
76
+ }
77
+
78
+ // bitwise AND assignment for exception_bits
79
+ inline exception_bits& operator&= (exception_bits& x, exception_bits y)
80
+ {
81
+ return x = x & y;
82
+ }
83
+
84
+ // bitwise OR assignment for exception_bits
85
+ inline exception_bits& operator|= (exception_bits& x, exception_bits y)
86
+ {
87
+ return x = x | y;
88
+ }
89
+
90
+ // bitwise NOT assignment for exception_bits
91
+ inline exception_bits& operator^= (exception_bits& x, exception_bits y)
92
+ {
93
+ return x = x ^ y;
94
+ }
95
+
96
+
97
+ /// \brief CWD specifying which exception type should be thrown.
98
+ ///
99
+ /// \return The current cwd of the active thread.
100
+ inline exception_bits& cwd()
101
+ {
102
+ // Thread local cwd
103
+ static exception_bits exception_cwd_ = none_bit;
104
+
105
+ return exception_cwd_;
106
+ }
107
+
108
+
109
+ /// \brief Set the control word of the active thread specifying which exception type should be thrown.
110
+ ///
111
+ /// \param new_state New control word
112
+ /// \return New control word
113
+ ///
114
+ inline exception_bits set_throw_exception_cwd(exception_bits new_state)
115
+ {
116
+ return (cwd() = new_state);
117
+ }
118
+
119
+ /// \brief Control word of the active thread specifying which exception type should be thrown.
120
+ ///
121
+ /// \return exception_bits Current control word
122
+ inline exception_bits get_throw_exception_cwd()
123
+ {
124
+ return cwd();
125
+ }
126
+
127
+ /// \brief Exception class specifying an undefined operation
128
+ ///
129
+ class exception : public std::runtime_error
130
+ {
131
+ public:
132
+ exception(std::string s)
133
+ : std::runtime_error(s)
134
+ { }
135
+ };
136
+
137
+
138
+ /// \brief Exception class specifying an undefined operation
139
+ ///
140
+ class undefined_operation_exception : public exception
141
+ {
142
+ public:
143
+ undefined_operation_exception()
144
+ : exception("Undefined operation exception!")
145
+ { }
146
+ };
147
+
148
+ /// \brief Exception class specifying a possibly undefined operation
149
+ ///
150
+ class possibly_undefined_operation_exception : public exception
151
+ {
152
+ public:
153
+ possibly_undefined_operation_exception()
154
+ : exception("possibly undefined operation exception!")
155
+ { }
156
+ };
157
+
158
+ /// \brief Exception class specifying an interval part of NaI exception
159
+ ///
160
+ class interval_part_of_nai_exception : public exception
161
+ {
162
+ public:
163
+ interval_part_of_nai_exception()
164
+ : exception("Interval part of NaI exception!")
165
+ { }
166
+ };
167
+
168
+ /// \brief Exception class specifying an invalid operand
169
+ ///
170
+ class invalid_operand_exception : public exception
171
+ {
172
+ public:
173
+ invalid_operand_exception()
174
+ : exception("Invalid operand exception!")
175
+ { }
176
+ };
177
+
178
+
179
+
180
+ /// \brief The current exception state.
181
+ ///
182
+ /// \return The current exception state of the active thread.
183
+ inline exception_bits& state()
184
+ {
185
+ // Thread local exception state
186
+ static exception_bits exception_state_ = none_bit;
187
+
188
+ return exception_state_;
189
+ }
190
+
191
+ /// \brief Clears the exception state.
192
+ ///
193
+ /// \return The current exception state of the active thread (= <c>none_bit</c>).
194
+ /// \note Thread local storage is used for the exception state.
195
+ inline exception_bits clear()
196
+ {
197
+ return state() = none_bit;
198
+ }
199
+
200
+ /// \brief Checks exception state for an undefined operation.
201
+ /// \return true if the <c>undefined_operation_bit</c> is set.
202
+ /// \note Thread local storage is used for the exception state.
203
+ inline bool undefined_operation()
204
+ {
205
+ return state() & undefined_operation_bit;
206
+ }
207
+
208
+ /// \brief Checks exception state for a possibly undefined operation.
209
+ /// \return true if the <c>possibly_undefined_operation_bit</c> is set.
210
+ /// \note Thread local storage is used for the exception state.
211
+ inline bool possibly_undefined_operation()
212
+ {
213
+ return state() & possibly_undefined_operation_bit;
214
+ }
215
+
216
+ /// \brief Checks exception state for an interval part of NaI exception.
217
+ /// \return true if the <c>interval_part_of_nai_bit</c> is set.
218
+ /// \note Thread local storage is used for the exception state.
219
+ inline bool interval_part_of_nai()
220
+ {
221
+ return state() & interval_part_of_nai_bit;
222
+ }
223
+
224
+ /// \brief Checks exception state for an invalid operation.
225
+ /// \return true if the <c>interval_part_of_nai_bit</c> is set.
226
+ /// \note Thread local storage is used for the exception state.
227
+ inline bool invalid_operand()
228
+ {
229
+ return state() & invalid_operand_bit;
230
+ }
231
+
232
+ /// \brief Adds the flag for an undefined operation to the exception state.
233
+ ///
234
+ /// \return The current exception state of the active thread (= old exception state <c>| undefined_operation_bit</c>) if no exception is thrown.
235
+ /// \exception undefined_operation_exception Throws exception if the <c>undefined_operation_bit</c> is set for the <c>throw_exception_cwd</c>.
236
+ /// \note Thread local storage is used for the exception state.
237
+ inline exception_bits signal_undefined_operation()
238
+ {
239
+ state() |= undefined_operation_bit;
240
+
241
+ // Throw exception if necessary
242
+ if (cwd() & undefined_operation_bit)
243
+ throw undefined_operation_exception();
244
+
245
+ return state();
246
+ }
247
+
248
+ /// \brief Adds the flag for a possibly undefined operation to the exception state.
249
+ ///
250
+ /// \return The current exception state of the active thread (= old exception state <c>| possibly_undefined_operation_bit</c>) if no exception is thrown.
251
+ /// \exception possibly_undefined_operation_exception Throws exception if the <c>possibly_undefined_operation_bit</c> is set for the <c>throw_exception_cwd</c>.
252
+ /// \note Thread local storage is used for the exception state.
253
+ inline exception_bits signal_possibly_undefined_operation()
254
+ {
255
+ state() |= possibly_undefined_operation_bit;
256
+
257
+ // Throw exception if necessary
258
+ if (cwd() & possibly_undefined_operation_bit)
259
+ throw possibly_undefined_operation_exception();
260
+
261
+ return state();
262
+ }
263
+
264
+ /// \brief Adds the flag for an interval part of NaI exception to the exception state.
265
+ ///
266
+ /// \return The current exception state of the active thread (= old exception state <c>| interval_part_of_nai_bit</c>) if no exception is thrown.
267
+ /// \exception interval_part_of_nai_exception Throws exception if the <c>interval_part_of_nai_bit</c> is set for the <c>throw_exception_cwd</c>.
268
+ /// \note Thread local storage is used for the exception state.
269
+ inline exception_bits signal_interval_part_of_nai()
270
+ {
271
+ state() |= interval_part_of_nai_bit;
272
+
273
+ // Throw exception if necessary
274
+ if (cwd() & interval_part_of_nai_bit)
275
+ throw interval_part_of_nai_exception();
276
+
277
+ return state();
278
+ }
279
+
280
+ /// \brief Adds the flag for an invalid operand to the exception state.
281
+ ///
282
+ /// \return The current exception state of the active thread (= old exception state <c>| invalid_operand_bit</c>) if no exception is thrown.
283
+ /// \exception invalid_operand_exception Throws exception if the <c>invalid_operand_bit</c> is set for the <c>throw_exception_cwd</c>.
284
+ /// \note Thread local storage is used for the exception state.
285
+ inline exception_bits signal_invalid_operand()
286
+ {
287
+ state() |= invalid_operand_bit;
288
+
289
+ // Throw exception if necessary
290
+ if (cwd() & invalid_operand_bit)
291
+ throw invalid_operand_exception();
292
+
293
+ return state();
294
+ }
295
+
296
+
297
+ } // namespace exception
298
+
299
+ } // namespace p1788
300
+
301
+
302
+ #endif // LIBIEEEP1788_P1788_EXCEPTION_EXCEPTION_HPP