Reputation: 79469
I'm writing a program that generates large prime numbers. Bigger than 2^32. How do I generate such big numbers in 32-bit C++? I use Windows 7 on 32-bit processor. I know I could get 64-bit support buy buying a new 64-bit computer, but it's not an option currently.
Upvotes: 1
Views: 2155
Reputation: 1908
There also is the GMP library for signed integers of arbitrary size even >2^64. The C++ interface makes the variables behave just like normal ints via operator overloading.
Upvotes: 0
Reputation: 67266
To print the number, use %lld
with printf:
long long variable;
printf( "your long long variable: %lld", variable );
Upvotes: 2
Reputation: 9415
Use long long
or include stdint.h
or cstdint
and use int64_t
and uint64_t
.
In addition to this, you can refer to Windows data types at http://msdn.microsoft.com/en-us/library/windows/desktop/aa383751%28v=vs.85%29.aspx
From this list, you can use DWORDLONG
, DWORD64
or INT64
.
Upvotes: 4
Reputation: 122443
Use long long
, which is at least 64-bit, and it's available in 32-bit machines as well.
Upvotes: 1