SIMONS

Greenhorn
+ Follow
since Nov 15, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by SIMONS

How can I tell which number will cause loss of precision in this case? If I replace 123456789 with:
5 -> no loss
500,000,000 -> no loss
500,000,001 -> loss
500,000,002 -> loss
500,000,010 -> loss
500,000,020 -> no loss
I cannot see a general rule of thumb. Please shed some lights.
The code that I use to test this:
public class Test {
public static void main(String[] args) {
int intNumber = (new Integer(args[0])).intValue();
float floatNumber = intNumber;
System.out.println("min: " + Math.min(
Integer.MAX_VALUE, intNumber));
System.out.println(floatNumber);
int x = (int)floatNumber;
System.out.println("x is " + x + " so " + (intNumber - x));
System.out.println(intNumber == x );
}
}