bug-gmp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with assignment operator


From: Linus Nordberg
Subject: Re: Problem with assignment operator
Date: Tue, 11 Jan 2005 20:40:21 +0100
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3

William Garrett Mitchener <address@hidden> wrote
Tue, 11 Jan 2005 13:57:33 -0500 (EST):

|  #include <gmp.h>
|  #include <gmpxx.h>
|  #include <iostream>
|  
|  using namespace std;
|  
|  int
|  main(int, char**)
|  {
|     mpz_class a, b;
|     a = 9;
|     b = -14;
|  
|     mpq_class c;
|     c = mpq_class(a, b); // seg fault here
|  
|     cout << c << endl;
|  }

The denominator mustn't be negative.  From the fine manual, section
Rational Number Functions:

     All rational arithmetic functions assume operands have a canonical
  form, and canonicalize their result.  The canonical from means that the
  denominator and the numerator have no common factors, and that the
  denominator is positive.  Zero has the unique representation 0/1.

Wether a segfault is a reasonable punishment for not obeying this rule
or not, I couldn't tell.  Cc to the GMP discussion list.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]