
-------- Original Message -------- Subject: Representing +inf, -inf and nan in mpq_class objects Date: Sat, 04 Oct 2003 09:29:41 +0200 From: Roberto Bagnara bagnara@cs.unipr.it Organization: Department of Mathematics, University of Parma, Italy To: gmp-discuss@swox.com
I need a class of rationals extended with +inf, -inf and nan, and I also need to minimize memory occupation. I am wondering if it is safe to represent them with the fractions 1/0, -1/0 and 0/0 as objects of type mpq_class. All the required operations (basically addition and comparisons is all I need) would be redefined so as to test for the special cases first and handle them in the appropriate way, resorting to normal mpz_class operations only for normal values.
So I guess the question is: is there something in the present (and, conceivably, future) design of mpz_class for which
- sticking 1/0, -1/0 or 0/0 into an object and - testing for the presence of such special values in an object
may cause wrong or undefined behavior? This may happen, e.g., if the (present or future) implementation does too much automatic canonicalization. What do you think? Cheers,
Roberto