Expression evaluation with variables and literals
When I wrote my 'big factorials' code here on Sololearn, I struggled with a problem. I tried to do this (pseudo code): llu big_n = huge int * huge int; My assumption was that if I just place a sufficiently large container, I can multiply two int variables and save the large result (yeah: pythonist ^^) . What happened? int*int overflowed and the distorted result got stored in the llu. It was a valuable lesson for me: int * int will be int, no warning. Today I read that a number literal without decimals is interpreted as type int by the compiler. I thought: Well, that would mean that two int literals would have to overflow as well, like: llu big_n = 2'100'000'000+3'000'000'000; Funnily enough, that didn't happen here on Sololearn. It seemed like the compiler somehow 'understood' that we needed something bigger here. On my PC though, I got a warning 'Overflow in expression' and a crazy result. I suppose this has to do with how Sololearn is set up, but can anyone explain what exactly is going on?