I get a strange problem on some android phone , when I run the code under.
public void test(){ int num = 1; for(int i=0;i<14;i++){ num = num+100000; } System.out.println("num "+num);} I expect the answer "1400001",but I get the wrong answer "200385" on the phone like MotoX 2ndGen , Xiaomi3,Xiaomi note etc. what's the strangest things is I can get the right answer when I want to debug it ,or complicate the code like public void test(){ int num = 1; for(int i=0;i<14;i++){ num = num+100000; System.out.println("num "+num); } } public void test(){ int num1 = 1; for(int i=0;i<14;i++){ num1 = num1+100000; } System.out.println("num1 "+num1); int num2 = 1; for(int i=0;i<14;i++){ num2 = num2+100000; } System.out.println("num2 "+num2); } or turn int to long ,or make "100000" to 100, it can get the right answer usually.So what the truly reason occur? int overflow? Thank you. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/d7ce70a1-a1e1-4849-9988-56d64d7e8d96%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.