Importing integers

Jernej Makovsek jernej.makovsek at gmail.com
Thu Feb 5 15:16:16 CET 2009


I wanted to print the value of t. gmp_printf.
If I read the file with mpz_import, gmp_printf(t %Zd\n, t) solves the
problem. But if I use  mpz_inp_raw instead of mpz_inport I get
compiler warning (parameter names (without types) in function
declaration) and on run t=0 which indicates an error from mpz_inp_raw.
 I read http://gmplib.org/manual/Parameter-Conventions.html#Parameter-Conventions,
http://gmplib.org/manual/I_002fO-of-Integers.html#I_002fO-of-Integers
and googled for this compiler warning but still I have no idea. So
could somebody give an example of mpz_inp_raw since it isn`t in demos/
folder?

 Thank you.

Jernej

On Thu, Feb 5, 2009 at 9:50 AM, Marc Glisse <marc.glisse at normalesup.org> wrote:
> On Wed, 4 Feb 2009, Jernej Makovsek wrote:
>
>> FILE *file;
>> file = fopen("/home/file", "rb");
>>
>> //inic
>> mpz_t t;
>> mpz_init (t);
>>
>> size_t mpz_inp_raw(t,file);
>>
>>        gmp_printf("file = %i\nt = %i\n", file, t);
>
> [...]
>>
>> Output:
>> file = 151445512
>> t = -1074788044
>>
>> where "file" and "t" values change everytime the program is run. Why`s
>> that?
>
> Hello,
>
> what exactly do you expect gmp_printf to do? The documentation is available
> here:
> http://gmplib.org/manual/Formatted-Output-Strings.html
> You may also want to have a look at the documentation of the basic printf
> function.
>
> Here you are telling your program to print 2 pointers converted to integers,
> so getting two random 32 bit numbers is not unreasonnable.
>
> --
> Marc Glisse
>


More information about the gmp-discuss mailing list