source: trunk/third/gmp/mpz/iset_str.c @ 18191

Revision 18191, 1.6 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18190, which included commits to RCS files with non-trunk default branches.
Line 
1/* mpz_init_set_str(string, base) -- Convert the \0-terminated string
2   STRING in base BASE to a multiple precision integer.  Return a MP_INT
3   structure representing the integer.  Allow white space in the
4   string.  If BASE == 0 determine the base in the C standard way,
5   i.e.  0xhh...h means base 16, 0oo...o means base 8, otherwise
6   assume base 10.
7
8Copyright 1991, 1993, 1994, 1995, 2000, 2001, 2002 Free Software Foundation,
9Inc.
10
11This file is part of the GNU MP Library.
12
13The GNU MP Library is free software; you can redistribute it and/or modify
14it under the terms of the GNU Lesser General Public License as published by
15the Free Software Foundation; either version 2.1 of the License, or (at your
16option) any later version.
17
18The GNU MP Library is distributed in the hope that it will be useful, but
19WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
21License for more details.
22
23You should have received a copy of the GNU Lesser General Public License
24along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
25the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
26MA 02111-1307, USA. */
27
28#include "gmp.h"
29#include "gmp-impl.h"
30
31int
32mpz_init_set_str (mpz_ptr x, const char *str, int base)
33{
34  x->_mp_alloc = 1;
35  x->_mp_d = (mp_ptr) (*__gmp_allocate_func) (BYTES_PER_MP_LIMB);
36
37  /* if str has no digits mpz_set_str leaves x->_mp_size unset */
38  x->_mp_size = 0;
39
40#ifdef __CHECKER__
41  /* let the low limb look initialized, for the benefit of mpz_get_ui etc */
42  x->_mp_d[0] = 0;
43#endif
44
45  return mpz_set_str (x, str, base);
46}
Note: See TracBrowser for help on using the repository browser.