floating point - java-Not getting the result with decimal places -


this question has answer here:

i doing simple calculation in java. expected result 51.3348 getting 51.0, here calculation

    float percent = (7819140000l-3805200000l)*100/7819140000l; 

is problem datatype? how can resolve value 51.3348

thanks in advance

add f 1 of values:

float percent = (7819140000l-3805200000l)*100f/7819140000l; 

if yiu not it, java make devision long values


Comments