Why doesn't this Java calculation return a floating point value? -
Just wanted to know
float percent = 1 + (25/100); // percent value is 1.0 and not 1.25 returns result 1 but not 1.25
thanks sqt
I think Java looks at it like this:
(int) 1 + (int) 25 / (int) 100) = (Int) 1 And then it is stored in a float. Try it with 25 instead of 25.0 .
Comments
Post a Comment