This is something that’s annoyed me for ages:
public class FPError
{
public static void main( String[] args )
{
float f = 0.0f;
for( int i = 0; i < 10; i++ )
{
f += 0.1f;
System.out.println( f );
}
}
}
gives
0.1
0.2
0.3
0.4
0.5
0.6
0.70000005
0.8000001
0.9000001
1.0000001
Where does this error come from? Is it really too much to ask that simple addition works?
