Re: mpz_set_si loses long long value on Windows

2019-07-24 Thread Vincent Lefevre
On 2019-07-24 13:45:22 +0200, Torbjorn Granlund wrote: > I think we should require C99 for GMP 7. Unfortunately, that's not enough. One practical issue is the MS-Windows environment (again) and the Microsoft runtime. We have the following in MPFR's INSTALL file (note the mention of GMP): 3 - To a

Re: mpz_set_si loses long long value on Windows

2019-07-24 Thread Torbjörn Granlund
Vincent Lefevre writes: On 2019-07-24 11:29:42 +0200, Torbjorn Granlund wrote: > The problem with MPFR's approach is that the library API depends on the > compiler. Yes, but note that this is also the case with GMP, for the formatted output functions. :) Yikes! I wasn't aware of that

Re: mpz_set_si loses long long value on Windows

2019-07-24 Thread Vincent Lefevre
On 2019-07-24 11:29:42 +0200, Torbjorn Granlund wrote: > The problem with MPFR's approach is that the library API depends on the > compiler. Yes, but note that this is also the case with GMP, for the formatted output functions. :) > (We could solve that issue by rejecting pre-C99 compilers. GMP

Re: mpz_set_si loses long long value on Windows

2019-07-24 Thread Torbjörn Granlund
Vincent Lefevre writes: GNU MPFR has mpfr_set_sj and mpfr_set_uj (when intmax_t is available) in addition to mpfr_set_si and mpfr_set_ui. Perhaps it could be nice for GMP to also have mpz_set_sj and mpz_set_uj in addition to mpz_set_si and mpz_set_ui. I have a probably incomplete patch

Re: mpz_set_si loses long long value on Windows

2019-07-24 Thread Vincent Lefevre
On 2019-07-24 11:11:46 +0200, Torbjorn Granlund wrote: > Dim XY writes: > This 'signed long int' type has different sizes of linux (8 bytes) and > windows 64bit (4 bytes) platforms > (https://en.cppreference.com/w/cpp/language/types) > > Maybe it is better to use 'long long' type which al

Re: mpz_set_si loses long long value on Windows

2019-07-24 Thread Torbjörn Granlund
Dim XY writes: a=-201032 // <- incorrect, lost value!! Possible explanation: mpz_set_si function has the signature: void mpz_set_si (mpz_ptr dest, signed long int val); Indeed. And you pass an int64_t which may or may not be "signed long int". That's a bug in your program,

mpz_set_si loses long long value on Windows

2019-07-24 Thread Dim XY
Hello, I'd like to report a problem with mpz_set_si on Windows 64 (Mingw) GMP version: 6.1.2 Platform: minw32 on linux ubuntu 18 the program to check: test-mpz.cpp: #include #include #include int main() { mpz_t mpz_a; int64_t a; int64_t b = 710;