Search code examples
javacalculus

java result really different from the expected one


I'm trying to output a really simple value, but what I obtain is really weird:

Log.d("try", "distanceWithMaxSpeed > " + ((90 * (1000 / 3600)) * ((3000 - 2000)/1000)) );

I get 0 instead of 25! Where am I wrong?


Solution

  • Integer Division

    1000/3600 = 0

    You should change them to floats (90f) or doubles (90.0)