+ 1
Mobile IDEs?
Why do mobile IDEs seem to not work properly? I've tried CPP N-IDE and C Mobile and both seem to handle this code incorrectly: #include <iostream> using namespace std; int main() { unsigned long long int n,x = 0; for(x=2;x<40;x=x+2){ n=2<<x; cout << x << " : " << n << endl ; } } Seems to just output 0 for all numbers past 31 Why does this happen? Is there an offline mobile IDE that works properly?
2 Réponses
+ 7
I use Termux with clang package installed. The output for your code appears to be similar to Code Playground's.
https://play.google.com/store/apps/details?id=com.termux
Anyway, it looks like n would overflow for 2 << x where x > 31. This should be causing the 0 values on the IDEs you mentioned. The mobile compilers are actually working fine: Overflow is, after all, undefined behaviour and the results are dependent on compiler implementation.
https://stackoverflow.com/questions/16188263/is-signed-integer-overflow-still-undefined-behavior-in-c
+ 2
It works on DCoder
https://play.google.com/store/apps/details?id=com.paprbit.dcoder