64bit integer literals on 32bit platforms
Gereon Kremer
gereon.kremer at cs.rwth-aachen.de
Tue Mar 22 08:59:43 UTC 2016
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Hi,
We once again run into this issue. This time, we have troubles with
std::int64_t and alike being typedef'd differently on different platforms.
This is only a problem with gmp though, as everything else just works
fine with both long and long long.
Could these constructors make it into 6.1?
As far as I understand it, it shouldn't be a big problem because it's
just another type name for the very same data, right?
Best,
Gereon
On 10/29/2015 09:19 PM, Marc Glisse wrote:
> On Thu, 29 Oct 2015, Gereon Kremer wrote:
>
>> We are using gmp in a library project that is supposed to work on both
>> 32bit and 64bit platforms.
>> However, we ran into problem when we used integer literals that are
>> larger than 2^32 (say 10000000000).
>> Consider the following code:
>>
>> #include <gmpxx.h>
>> int main() {
>> mpz_class x(10000000000);
>> }
>>
>> On 64bit platforms, everything will be fine. On 32bit however, gmp only
>> provides constructors from char, short, int and long int, but not long
>> long int. Thus, compilers (g++, clang++) will tell you that the
>> constructor is ambiguous.
>>
>> Tested on Ubuntu 14.04 (32bit), prepackaged gmp 5.1.3, g++ 4.8.2,
>> clang++ 3.4
>
> We should eventually support long long...
> Note that you could use strings for numbers of arbitrary size:
> mpz_class
x("10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
> or in C++11:
> mpz_class
x=10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000_mpz;
>
- --
Gereon Kremer
Lehr- und Forschungsgebiet Theorie Hybrider Systeme
RWTH Aachen
Tel: +49 241 80 21243
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQEcBAEBCAAGBQJW8Ql8AAoJEIQ2nMX673HfucsH/2Rif94JaJgIGnaBP9FZ/TOY
9RoY76xgAMJrD8Otz8coysg1xJpq6r4FkIHMIhztAnrT1C7B23qSDoKbXGSz8JGY
l8NoH2vRJAoK8EIRrvgLyWd5UHsBudfZL4T9cGEDaCfvyVd+pLXp8hmObeypx/ZQ
LZqVXdqHS3hPznMJMHZDVb05FQwEmndwkQVnwIMCP9XaY7jhs34xhBfpFtNzm4uN
03xroX1kANSCxt1iKfc+MSRDmh7ep8q31lPM7jlQj4DZv26XjPwL/sTSSaM2tMmh
WQylrMyh17JVM9uwW+prSRv69GQMIETIZ7BqmoWdLuhQw8DcWymnxogBTckP9pk=
=jB9O
-----END PGP SIGNATURE-----
More information about the gmp-bugs
mailing list