R
Rene
The following code:
float someFloat = 0;
for(int x = 1; x <= 10; x++)
{
someFloat += .1F;
Console.WriteLine(someFloat.ToString());
}
Returns:
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8000001
0.9000001
1
WHY, WHY, WHY, WHY, WHY, WHY, WHY, WHY, WHY, WHY, WHY!!! What happened to
the nice and rounded 0.8 and 0.9? I know that the float variable is prone to
rounding issues but come on!! I am just adding a 0.1. I haven't even gotten
to where it needs to start rounding!! What's going on???? Is this normal? It
probaly is, isn't it?
Thaks for any help.
float someFloat = 0;
for(int x = 1; x <= 10; x++)
{
someFloat += .1F;
Console.WriteLine(someFloat.ToString());
}
Returns:
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8000001
0.9000001
1
WHY, WHY, WHY, WHY, WHY, WHY, WHY, WHY, WHY, WHY, WHY!!! What happened to
the nice and rounded 0.8 and 0.9? I know that the float variable is prone to
rounding issues but come on!! I am just adding a 0.1. I haven't even gotten
to where it needs to start rounding!! What's going on???? Is this normal? It
probaly is, isn't it?
Thaks for any help.