Re: mpz_powm_ui () for 5.1.2

2017-03-07 Thread Niels Möller
Marco Bodrato  writes:

> Does "mingw32" means unsigned long is a 32-bit type?
> You should use an mpz variable to store values exceeding 2^32...

mingw means the microsoft windows abi. And on microsoft windows, "long"
is always 32 bits, even on x86_64 (not sure about windows on arm64,
though, I haven't bothered to ever try compiling anything for windows
phones).

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: mpz_powm_ui () for 5.1.2

2017-03-07 Thread Marco Bodrato

Ciao,

Il 2017-03-08 02:17 shen lixing ha scritto:

I installed MinGW, then  'mingw-get install mingw32-gmp' , got the gmp
5.1.2 properly.


The last release of the library is 6.1.2 .


unsigned long long c = 10307e7 - 1;  // change c,start point



  mpz_set_ui(b,c);
  mpz_mul_ui(b,b,c);
  mpz_powm_ui(d,a,c-1,b );


Look carefully at the documentation of the three mpz*_ui functions you 
use.

They take an _unsigned long_ as their _ui argument.
You pass an _unsigned long long_ variable, the compiler implicitly 
casts.


Does "mingw32" means unsigned long is a 32-bit type?
You should use an mpz variable to store values exceeding 2^32...

Regards,
m

--
http://bodrato.it/papers/
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


mpz_powm_ui () for 5.1.2

2017-03-07 Thread shen lixing
Hi,

developer!


I installed MinGW, then  'mingw-get install mingw32-gmp' , got the gmp 5.1.2 
properly.

mpz_powm_ui ()  give a wrong calculation as below (compared and confirmed by 
Python):


// 2^(c-1) = 1 mod c^2, c = ?
#include 
#include 
#include 

int main()
{   printf("hello, world! \n");
unsigned long long c = 10307e7 - 1;  // change c,start point
printf("c reach  %llu \n",c);
mpz_t a,b,d;
mpz_inits(a,b,d,NULL);
mpz_set_ui(a,2);

for (; ;c += 2)
{ if (c % 1 == 1)
  { printf("c reach  %llu, %llu \n",c,(unsigned long long)time(NULL));
  }
  mpz_set_ui(b,c);
  mpz_mul_ui(b,b,c);
  mpz_powm_ui(d,a,c-1,b );
  if (mpz_cmp_ui(d,1) == 0)  // c = 1093,3511 are solutions.  why 
103079216179 ?
  { printf("found %llu \n",c);
return 0;
  }
}
}

I saw a bug report for the mpz_powm_ui () in 5.1.1. from https://gmplib.org.


Regards,

shen lixing

2017/3/8

GNU Multiple Precision Arithmetic Library - gmplib
gmplib.org
What is GMP? GMP is a free library for arbitrary precision arithmetic, 
operating on signed integers, rational numbers, and floating-point numbers.


___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: mpf_get_d_2exp ignores sign of input

2017-03-07 Thread Torbjörn Granlund
paul zimmermann  writes:

  I disagree. The fine manual says "D * 2^EXP is the (truncated) OP value",
  which is wrong if say OP = -0.5.
  
  And why bother write 0.5<=abs(D)<1 instead of 0.5<=D<1 if D is always >= 0?
  
Right.  I am testing a fix, and am also rewriting the documentation to
be more readable.
  

-- 
Torbjörn
Please encrypt, key id 0xC8601622
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: mpf_get_d_2exp ignores sign of input

2017-03-07 Thread paul zimmermann
   Torbjörn,

>   mpf_get_d_2exp() always returns a non-negative value, even for negative
>   input.  I think this is a bug.
>   
> The function works as documented.  No bug.

I disagree. The fine manual says "D * 2^EXP is the (truncated) OP value",
which is wrong if say OP = -0.5.

And why bother write 0.5<=abs(D)<1 instead of 0.5<=D<1 if D is always >= 0?

Paul
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs


Re: mpf_get_d_2exp ignores sign of input

2017-03-07 Thread Torbjörn Granlund
Claude Heiland-Allen  writes:

  mpf_get_d_2exp() always returns a non-negative value, even for negative
  input.  I think this is a bug.
  
The function works as documented.  No bug.

-- 
Torbjörn
Please encrypt, key id 0xC8601622
___
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs