~ubuntu-branches/ubuntu/intrepid/ecl/intrepid

« back to all changes in this revision

Viewing changes to src/gmp/mpq/set_ui.c

  • Committer: Bazaar Package Importer
  • Author(s): Peter Van Eynde
  • Date: 2007-04-09 11:51:51 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070409115151-ql8cr0kalzx1jmla
Tags: 0.9i-20070324-2
Upload to unstable. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* mpq_set_ui(dest,ulong_num,ulong_den) -- Set DEST to the retional number
 
1
/* mpq_set_ui(dest,ulong_num,ulong_den) -- Set DEST to the rational number
2
2
   ULONG_NUM/ULONG_DEN.
3
3
 
4
 
Copyright 1991, 1994, 1995, 2001 Free Software Foundation, Inc.
 
4
Copyright 1991, 1994, 1995, 2001, 2002, 2003 Free Software Foundation, Inc.
5
5
 
6
6
This file is part of the GNU MP Library.
7
7
 
17
17
 
18
18
You should have received a copy of the GNU Lesser General Public License
19
19
along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
20
 
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21
 
MA 02111-1307, USA. */
 
20
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
21
MA 02110-1301, USA. */
22
22
 
23
23
#include "gmp.h"
24
24
#include "gmp-impl.h"
26
26
void
27
27
mpq_set_ui (MP_RAT *dest, unsigned long int num, unsigned long int den)
28
28
{
 
29
  if (GMP_NUMB_BITS < BITS_PER_ULONG)
 
30
    {
 
31
      if (num == 0)  /* Canonicalize 0/d to 0/1.  */
 
32
        den = 1;
 
33
      mpz_set_ui (mpq_numref (dest), num);
 
34
      mpz_set_ui (mpq_denref (dest), den);
 
35
      return;
 
36
    }
 
37
 
29
38
  if (num == 0)
30
39
    {
31
40
      /* Canonicalize 0/n to 0/1.  */