@Ganado
For right now it is a simulation, but I was hoping to one day apply it to a remote-controlled car with a GPS unit on it. I would guess that even then, the small amount of error isn't going to be an issue. It isn't like I would be driving long distances.
And you are right about the replay. I would like to eventually work with pathfinding and pre-plan a path, hence I would have to program in some kind of instructions for the car to follow, and assure that it always reached its goal.
No galactic simulations (though that sounds like fun), and definitely not missile interception... driving hobby-level robots or RC cars around is my eventual goal.
@dhayden
I see your point. The error number would be of little significance.
As an interesting side note, I actually did a test with large amounts of increments, and it seems like the error actually diminishes at a certain point and then simply bounces around.
The error peaked at about 671,000,000 loops before decreasing:
... error increasing ...
670,000,000 loops, count is 67,000,000.7042601
671,000,000 loops, count is 67,100,000.7057503
672,000,000 loops, count is 67,200,000.7004502
... error decreasing ...
I'm not sure exactly why this is occurring at that amount... maybe something inherent to the double. Here's the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
int main()
{
uint count = 0;
uint a = 1000000;
double b = 0.0;
while (true)
{
for (uint i = 0; i < a; i++)
b += 0.1;
count++;
uint temp = count * a;
std::cout << "Loops: " << temp << "\n";
std::cout << "Number: " << b << "\n\n";
}
return 0;
}
|