I need to bruteforce a year for an exercise. The compiler keep throwing this error:
bruteforceJS12.cpp:8:28: warning: integer constant is too large fo
A quick way to figure out the numeric limits on your system would be to use std::numeric_limits. The output on my system when I run the following code:
#include <iostream>
#include <limits>
int main()
{
std::cout << "ull\t"
<< std::numeric_limits<unsigned long long>::lowest() << '\t'
<< std::numeric_limits<unsigned long long>::max() << std::endl ;
}
is:
ull 0 18446744073709551615
we can see the max value is definitely smaller than your literal value:
18446744073709551615
318338237039211050000
So your integer literal is just too large for unsigned long long type.
Your problem is simply that 318338237039211050000ULL
is out of range.
Assuming a 64 bit type, a 64 bit value is good for log10( 264-1) decimal digits (i.e. all 19 digit values and some lower 20 digit values), 318338237039211050000ull
has 21 digits. 264-1 (18446744073709551615ull
) is the maximum.
The value 318338237039211050000 requires at least log10(318338237039211050000)/log10(2) bits. That's 69 bits.