We know that using 1LL is necessary if we are shifting more than 32 bits but i have seen a lot of coders doing :
variable1 = (varialbe2+1LL)%mod
where variable1 and variable2 are in long long already.
Since we know that whenever we operate int and long long overall operations take place in long long . Then why most people do it ?
I mostly do it during contest to avoid penalty but afaik i never saw my program giving WA/TLE/RE if i do :
variable1 = (varialbe2+1)%mod
Has any one ever experienced that it's necessary to typecast operand which is in int to long long even if other operand is in long long already ?
It is not necessary. I think it is either a force of habit or trying to be safe, in case you think that you coded variable1 as LL even though it was actually int. It is the same reason as why you would place asserts in long codes. If we were perfect coders, there would be no need for it. But we aren't :D
Good question
It's easier to always use
1LL
(or1L
in Java/Kotlin) than to think about when it's fine to use 1 (in which case you can also make a mistake). It also makes the code clearer (it makes it clear that you're working with longs). For a similar reason, when using an int variable in long calculations I always cast to long even when my IDE tells me that it's unnecessary.