Why doesn't this Java calculation return a floating point value? -


just wanted know

float percent = 1 + (25/100); // percent value 1.0 , not 1.25 

the result gives 1 not 1.25

thanks saikat

i think it's because java sees this:

(int) 1 + ( (int)25/ (int)100) = (int) 1 

and it's stored float. try 25.0 instead of 25.


Comments