C++ : integer constant is too large for its type

后端 未结 2 1034
误落风尘
误落风尘 2021-01-16 09:48

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

2条回答
  •  无人及你
    2021-01-16 10:04

    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.

提交回复
热议问题