Answer the question
In order to leave comments, you need to log in
Why, when adding 0.001 of type float or doable 1000 times, after a few zeros after the decimal point, more numbers appear out of nowhere and how to solve it?
static void Main()
{
float a = 0.001f;
for (int i = 0; i < 1000; i++)
{
a += 0.001f;
}
Console.Write(a);
}
static void Main()
{
double a = 0.001;
for (int i = 0; i < 1000; i++)
{
a += 0.001;
}
Console.Write(a);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question