Hi, I have following: int maxFileSize = 4000, int temp can be any int value. Now I have to detect value of int numOfSegments depends on the what temp/maxFileSize returns. So, let's say, if temp/maxFileSize is 4000/4000, or 8000/4000 or 12000/4, then I can simply detect value of numOfSegments 0 or 1 or 2 respectively. BUT if temp/maxFileSize is 5000/4000 then it should return float. How can I determine whether it(temp/maxFileSize) will return float or int? Thanks, Angela
Angela If temp % maxFileSize returns anything other than 0 your going to get a float as the result of temp/maxFileSize, otherwise it'll be an int. Why can't you just get a float back and use that: float f = temp/maxFileSize;
To always get a float result, you can use: float result = ((float)temp)/maxSize; The result is not integral if result>temp/maxSize.
Ivor Horton<br />Author of the Beginning Java Series including the new <a href="http://www.amazon.com/exec/obidos/ASIN/1861005695/ref=ase_electricporkchop" target="_blank" rel="nofollow">Beginning Java 2 SDK 1.4 Edition</a>