Yes, you already said that, but can you please share the exact code that produces the output? Taking your snippets from above and throwing them into main on the playground produces the cited compilation errors.
With an int64 you won’t get int32 rollover behaviour, thats exactly what I meant when I said " PS: Forcing int32 might already be enough, 201920192019 does already overflow then though…".
I understand, but is it possible to simulate a 32-bit number from a 64-bit one? I tried to take away a 32 bit number with distinct coefficients and sometimes it worked, but for a specific value.
It worked for a specific value, and if I changed the value, it no longer worked.
It was something like 1 << 32, (1 << 32) * 5 (these are the coefficients that I mentioned above).
It’s because when you use constants and bit shifts on constants, the compiler folds them into constants and knows they’re out of range. By putting the conversion from int64 to int32 into a function, the overflow is deferred until runtime where overflow is unchecked.