[PPL-devel] [Fwd: Representing +inf, -inf and nan in mpq_class objects]

Roberto Bagnara bagnara at cs.unipr.it
Tue Oct 7 09:36:41 CEST 2003



-------- 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 at cs.unipr.it>
Organization: Department of Mathematics, University of Parma, Italy
To: gmp-discuss at 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

-- 
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it

_______________________________________________
gmp-discuss mailing list
gmp-discuss at swox.com
http://swox.com/mailman/listinfo/gmp-discuss


-- 
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it




More information about the PPL-devel mailing list