Re: GMP Problem with % under C++

2020-11-06 Thread Torbjörn Granlund
Miki Hermann writes: I am very well familiar with the % operator in %. Swell. In the document, whose link you sent me, and which I have read before, it is mentioned that Function: mpz_class operator% (mpz_class a, mpz_class d) This means, that the % operator in GMP overloads the

Re: GMP Problem with % under C++

2020-11-06 Thread Miki Hermann
I am very well familiar with the % operator in %. In the document, whose link you sent me, and which I have read before, it is mentioned that Function: mpz_class operator% (mpz_class a, mpz_class d) This means, that the % operator in GMP overloads the usual % operator in C++. Just to recall

Re: GMP Problem with % under C++

2020-11-06 Thread sisyphus
On Fri, Nov 6, 2020 at 8:27 AM Niels Möller wrote: > [snip] > > So your problem really is with % in C++, GMP just follows the > conventions for the builtin integers. > Rather, the OP is expecting that the ''%" operator in his C++ program will behave as mpz_mod() does - which is the same way as

Re: GMP Problem with % under C++

2020-11-05 Thread Marco Bodrato
Ciao, Il 2020-11-05 22:27 Niels Möller ha scritto: I think this is the same result you get with a plain (64-bit) long. The / and % operators in C++ produce a quotient rounded towards 0, so (f(1) - b) / DECKSIZE == 0, and the corresponding remainder is negative. I'm not that familiar with

Re: GMP Problem with % under C++

2020-11-05 Thread Niels Möller
Miki Hermann writes: > The result of the command '22b-gmp < 22input.txt' is: > >*** b = 62010736820046 >f(1) - b = -15681174147849 >a = -15681174147849 >On position 2020 is the card 102220661749926 I think this is the same result you get with a plain (64-bit) long. The / and %

Re: GMP Problem with % under C++

2020-11-05 Thread Marc Glisse
On Thu, 5 Nov 2020, Miki Hermann wrote: I am not sure if I used the GMP package properly or if I did everything right, but it seems to me that very probably there is a problem somewhere in the GMP package and/or its interface with C++. It is very probable that you are not familiar with the %

GMP Problem with % under C++

2020-11-05 Thread Miki Hermann
Dear Sirs. I have installed and started to use the GMP library. I wanted to use it on Part B of the problem presented in Advent of Code 2019 on Day 22. Previously, I was able to solve that problem only in Perl, using the bigint library. I am using Fedora 33. I downloaded and installed the GMP