init.c revision 1.1.1.1.2.1 1 1.1 mrg /* mpq_init -- Make a new rational number with value 0/1.
2 1.1 mrg
3 1.1 mrg Copyright 1991, 1994, 1995, 2000, 2001, 2002 Free Software Foundation, Inc.
4 1.1 mrg
5 1.1 mrg This file is part of the GNU MP Library.
6 1.1 mrg
7 1.1 mrg The GNU MP Library is free software; you can redistribute it and/or modify
8 1.1 mrg it under the terms of the GNU Lesser General Public License as published by
9 1.1 mrg the Free Software Foundation; either version 3 of the License, or (at your
10 1.1 mrg option) any later version.
11 1.1 mrg
12 1.1 mrg The GNU MP Library is distributed in the hope that it will be useful, but
13 1.1 mrg WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 1.1 mrg or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 1.1 mrg License for more details.
16 1.1 mrg
17 1.1 mrg You should have received a copy of the GNU Lesser General Public License
18 1.1 mrg along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
19 1.1 mrg
20 1.1 mrg #include "gmp.h"
21 1.1 mrg #include "gmp-impl.h"
22 1.1 mrg
23 1.1 mrg void
24 1.1 mrg mpq_init (MP_RAT *x)
25 1.1 mrg {
26 1.1.1.1.2.1 yamt ALLOC(NUM(x)) = 1;
27 1.1.1.1.2.1 yamt PTR(NUM(x)) = (mp_ptr) (*__gmp_allocate_func) (BYTES_PER_MP_LIMB);
28 1.1.1.1.2.1 yamt SIZ(NUM(x)) = 0;
29 1.1.1.1.2.1 yamt ALLOC(DEN(x)) = 1;
30 1.1.1.1.2.1 yamt PTR(DEN(x)) = (mp_ptr) (*__gmp_allocate_func) (BYTES_PER_MP_LIMB);
31 1.1.1.1.2.1 yamt PTR(DEN(x))[0] = 1;
32 1.1.1.1.2.1 yamt SIZ(DEN(x)) = 1;
33 1.1 mrg
34 1.1 mrg #ifdef __CHECKER__
35 1.1 mrg /* let the low limb look initialized, for the benefit of mpz_get_ui etc */
36 1.1.1.1.2.1 yamt PTR(NUM(x))[0] = 0;
37 1.1 mrg #endif
38 1.1 mrg }
39