i know what you mean. but there is more than what meets the eye.
let's simplify the code to make sense
int ss = 10000890;
float f = ss;
System.out.println((int)f);
fine. now it really makes sense of what we are talking about. "PRECISION"
here as above it is, there is no loss. BUT make the number 100000890 (added another zero). yes NOW THERE IS A LOSS. output is ...888 loss of 2
so after some quantity or magnitude the loss appears.
Rob, but your point of precision loss is well taken, the only thing is that after certain magnitude the loss sets in.
Originally posted by Rob Ross:
Hehe, I can understand your confusion Mark, but I meant what I said
public class Conversion{
public static void main(String[] args){
int i = 1234567890;
float f = i;
System.out.println(i - (int)f);
}
}
the float f = i is an implicit widening conversion, even though it causes a loss of precision!
The idea behind it is that it is ok to loose a little precision as long as the overall magnitude of the number is not lost.
Rob