Tuesday, 20 August 2013

Getting wrong value when multiplying

Getting wrong value when multiplying

I am writing an Android app and I have an algorithm to calculate some
score out of several variables but when computing, I get wrong answer:
I get 10300 when I set mv, ptv, txtv to 10 whereas I should get 100. When
I set it to 1, I get 300 as answer.
int f;
f = (((mv*ptv*txtv)/10^3)*100);
int finalScr = f;
TextView scoreView = (TextView)findViewById(R.id.textView3);
scoreView.setText(Integer.toString(finalScr));
All the variables are integers and the maximum value of all the variables
is 10 and minimum is 1.
Please help.. I don't think I am mathematically wrong :P

No comments:

Post a Comment